diff --git a/ajax/deploypackage_form.php b/ajax/deploypackage_form.php
index d24083645..6c9d74219 100644
--- a/ajax/deploypackage_form.php
+++ b/ajax/deploypackage_form.php
@@ -65,7 +65,7 @@
$item = new $itemtype();
$item->move_item($params);
} else {
- Toolbox::logDebug("package subtype not found : " . $params['itemtype']);
+ Toolbox::logDebug("package subtype not found : " . $itemtype);
Html::displayErrorAndDie ("package subtype not found");
}
diff --git a/ajax/deployuser.logged.in.php b/ajax/deployuser.logged.in.php
deleted file mode 100644
index 874bf232f..000000000
--- a/ajax/deployuser.logged.in.php
+++ /dev/null
@@ -1,59 +0,0 @@
-.
- *
- * ------------------------------------------------------------------------
- *
- * This file is called by ajax function and display deploy user logged.
- *
- * ------------------------------------------------------------------------
- *
- * @package FusionInventory
- * @author Kevin Roy
- * @author David Durieux
- * @copyright Copyright (c) 2010-2023 FusionInventory team
- * @license AGPL License 3.0 or (at your option) any later version
- * http://www.gnu.org/licenses/agpl-3.0-standalone.html
- * @link http://www.fusioninventory.org/
- * @link https://github.com/fusioninventory/fusioninventory-for-gsit
- *
- */
-
-include ("../../../inc/includes.php");
-
-$loggedin = [];
-$loggedin['result'] = 1;
-if (!isset($_SESSION["glpiname"])) {
- if (!Session::getLoginUserID()) {
- $loggedin['result'] = 0;
- }
-}
-
-echo json_encode($loggedin);
-
diff --git a/ajax/dropdownactiontype.php b/ajax/dropdownactiontype.php
deleted file mode 100644
index 1d6c36979..000000000
--- a/ajax/dropdownactiontype.php
+++ /dev/null
@@ -1,59 +0,0 @@
-.
- *
- * ------------------------------------------------------------------------
- *
- * This file is called by ajax function and display dropdown action types.
- *
- * ------------------------------------------------------------------------
- *
- * @package FusionInventory
- * @author David Durieux
- * @copyright Copyright (c) 2010-2023 FusionInventory team
- * @license AGPL License 3.0 or (at your option) any later version
- * http://www.gnu.org/licenses/agpl-3.0-standalone.html
- * @link http://www.fusioninventory.org/
- * @link https://github.com/fusioninventory/fusioninventory-for-gsit
- *
- */
-
-if (strpos(filter_input(INPUT_SERVER, "PHP_SELF"), "dropdownactiontype.php")) {
- include ("../../../inc/includes.php");
- header("Content-Type: text/html; charset=UTF-8");
- Html::header_nocache();
-}
-
-Session::checkCentralAccess();
-
-$pfTaskjob = new PluginFusioninventoryTaskjob;
-$pfTaskjob->dropdownActionType(
- "ActionType",
- filter_input(INPUT_POST, "method"),
- '');
diff --git a/ajax/dropdowndefinitionselection.php b/ajax/dropdowndefinitionselection.php
deleted file mode 100644
index 711074bf7..000000000
--- a/ajax/dropdowndefinitionselection.php
+++ /dev/null
@@ -1,80 +0,0 @@
-.
- *
- * ------------------------------------------------------------------------
- *
- * This file is called by ajax function and display dropdown task
- * definition selection.
- *
- * ------------------------------------------------------------------------
- *
- * @package FusionInventory
- * @author David Durieux
- * @copyright Copyright (c) 2010-2023 FusionInventory team
- * @license AGPL License 3.0 or (at your option) any later version
- * http://www.gnu.org/licenses/agpl-3.0-standalone.html
- * @link http://www.fusioninventory.org/
- * @link https://github.com/fusioninventory/fusioninventory-for-gsit
- *
- */
-
-if (strpos(filter_input(INPUT_SERVER, "PHP_SELF"), "dropdowndefinitionselection.php")) {
- include ("../../../inc/includes.php");
- header("Content-Type: text/html; charset=UTF-8");
- Html::header_nocache();
-}
-if (!defined('GLPI_ROOT') || !isset($CFG_GLPI)) {
- die("Can not acces directly to this file");
-}
-Session::checkCentralAccess();
-
-echo "";
-
diff --git a/ajax/dropdowndefinitiontypelist.php b/ajax/dropdowndefinitiontypelist.php
deleted file mode 100644
index 1d897f0ea..000000000
--- a/ajax/dropdowndefinitiontypelist.php
+++ /dev/null
@@ -1,65 +0,0 @@
-.
- *
- * ------------------------------------------------------------------------
- *
- * This file is called by ajax function and display dropdown task
- * definition type list.
- *
- * ------------------------------------------------------------------------
- *
- * @package FusionInventory
- * @author David Durieux
- * @copyright Copyright (c) 2010-2023 FusionInventory team
- * @license AGPL License 3.0 or (at your option) any later version
- * http://www.gnu.org/licenses/agpl-3.0-standalone.html
- * @link http://www.fusioninventory.org/
- * @link https://github.com/fusioninventory/fusioninventory-for-gsit
- *
- */
-
-if (strpos(filter_input(INPUT_SERVER, "PHP_SELF"), "dropdowndefinitiontypelist.php")) {
- include ("../../../inc/includes.php");
- header("Content-Type: text/html; charset=UTF-8");
- Html::header_nocache();
-}
-if (!defined('GLPI_ROOT')) {
- die("Can not acces directly to this file");
-}
-
-Session::checkCentralAccess();
-$pfTaskjob = new PluginFusioninventoryTaskjob();
-$pfTaskjob->dropdownDefinition(
- "DefinitionList",
- filter_input(INPUT_POST, "DefinitionType"),
- filter_input(INPUT_POST, "method"),
- filter_input(INPUT_POST, "deftypeid"),
- filter_input(INPUT_POST, "taskjobs_id"));
-
diff --git a/ajax/dropdownjobdefinition.php b/ajax/dropdownjobdefinition.php
deleted file mode 100644
index 777f2f426..000000000
--- a/ajax/dropdownjobdefinition.php
+++ /dev/null
@@ -1,119 +0,0 @@
-.
- *
- * ------------------------------------------------------------------------
- *
- * This file is called by ajax function and display dropdown task job
- * definition.
- *
- * ------------------------------------------------------------------------
- *
- * @package FusionInventory
- * @author David Durieux
- * @copyright Copyright (c) 2010-2023 FusionInventory team
- * @license AGPL License 3.0 or (at your option) any later version
- * http://www.gnu.org/licenses/agpl-3.0-standalone.html
- * @link http://www.fusioninventory.org/
- * @link https://github.com/fusioninventory/fusioninventory-for-gsit
- *
- */
-
-include ("../../../inc/includes.php");
-
-header("Content-Type: text/html; charset=UTF-8");
-Html::header_nocache();
-Session::checkCentralAccess();
-
-// Make a select box
-$type = filter_input(INPUT_POST, "type");
-$actortype = filter_input(INPUT_POST, "actortype");
-
-if (!empty($type) && !empty($actortype)) {
- $rand = mt_rand();
-
- $entity_restrict = filter_input(INPUT_POST, "entity_restrict");
- switch ($type) {
- case "user" :
- $right = 'all';
- /// TODO : review depending of itil object
- // Only steal or own ticket whit empty assign
- if ($actortype == 'assign') {
- $right = "own_ticket";
- if (!$item->canAssign()) {
- $right = 'id';
- }
- }
-
- $options = ['name' => '_itil_'.$actortype.'[users_id]',
- 'entity' => $entity_restrict,
- 'right' => $right,
- 'ldap_import' => true];
- $withemail = false;
- if ($CFG_GLPI["use_mailing"]) {
- $allow_email = filter_input(INPUT_POST, "allow_email");
- $withemail = (!empty($allow_email) ? $allow_email : false);
- $paramscomment = ['value' => '__VALUE__',
- 'allow_email' => $withemail,
- 'field' => "_itil_".$actortype];
- // Fix rand value
- $options['rand'] = $rand;
- $options['toupdate'] = ['value_fieldname' => 'value',
- 'to_update' => "notif_user_$rand",
- 'url' => $CFG_GLPI["root_doc"]."/ajax/uemailUpdate.php",
- 'moreparams' => $paramscomment];
- }
- $rand = User::dropdown($options);
-
- if ($CFG_GLPI["use_mailing"]==1) {
- echo "
";
- if ($withemail) {
- echo __('Email followup').' : ';
- $rand = Dropdown::showYesNo('_itil_'.$actortype.'[use_notification]', 1);
- echo '
'.__('Email').' : ';
- echo "";
- }
- echo "";
- }
- break;
-
- case "group" :
- $cond = ($actortype=='assign' ? $cond = '`is_assign`' : $cond = '`is_requester`');
- Dropdown::show('Group', ['name' => '_itil_'.$actortype.'[groups_id]',
- 'entity' => $entity_restrict,
- 'condition' => $cond]);
- break;
-
- case "supplier" :
- Dropdown::show('Supplier', ['name' => 'suppliers_id_assign',
- 'entity' => $entity_restrict]);
- break;
- }
-}
-
diff --git a/ajax/dropdowntype.php b/ajax/dropdowntype.php
deleted file mode 100644
index 5f734ebe1..000000000
--- a/ajax/dropdowntype.php
+++ /dev/null
@@ -1,65 +0,0 @@
-.
- *
- * ------------------------------------------------------------------------
- *
- * This file is called by ajax function and display dropdown method types.
- *
- * ------------------------------------------------------------------------
- *
- * @package FusionInventory
- * @author David Durieux
- * @copyright Copyright (c) 2010-2023 FusionInventory team
- * @license AGPL License 3.0 or (at your option) any later version
- * http://www.gnu.org/licenses/agpl-3.0-standalone.html
- * @link http://www.fusioninventory.org/
- * @link https://github.com/fusioninventory/fusioninventory-for-gsit
- *
- */
-
-if (strpos(filter_input(INPUT_SERVER, "PHP_SELF"), "dropdowntype.php")) {
- include ("../../../inc/includes.php");
- header("Content-Type: text/html; charset=UTF-8");
- Html::header_nocache();
-}
-
-Session::checkCentralAccess();
-
-$typename = filter_input(INPUT_POST, "typename");
-$method = filter_input(INPUT_POST, "method");
-$taskjobs_id = filter_input(INPUT_POST, "taskjobs_id");
-
-$pfTaskjob = new PluginFusioninventoryTaskjob();
-if (!empty($typename)
- && !empty($method)
- && !empty($taskjobs_id)) {
- $pfTaskjob->dropdownType($typename, $method,
- filter_input(INPUT_POST, "value"), $taskjobs_id, "");
-}
diff --git a/ajax/taskjob_form.php b/ajax/taskjob_form.php
index 293197fbb..7ba5763cd 100644
--- a/ajax/taskjob_form.php
+++ b/ajax/taskjob_form.php
@@ -62,7 +62,7 @@
"task_id" => filter_input(INPUT_GET, "task_id")
];
-if (is_null($params['id']) || is_null($params['task_id'])) {
+if (is_null($params['id']) && is_null($params['task_id'])) {
exit;
}
diff --git a/ajax/taskjobdeletetype.php b/ajax/taskjobdeletetype.php
deleted file mode 100644
index 05e834510..000000000
--- a/ajax/taskjobdeletetype.php
+++ /dev/null
@@ -1,70 +0,0 @@
-.
- *
- * ------------------------------------------------------------------------
- *
- * This file is called by ajax function and delete task job type.
- *
- * ------------------------------------------------------------------------
- *
- * @package FusionInventory
- * @author David Durieux
- * @copyright Copyright (c) 2010-2023 FusionInventory team
- * @license AGPL License 3.0 or (at your option) any later version
- * http://www.gnu.org/licenses/agpl-3.0-standalone.html
- * @link http://www.fusioninventory.org/
- * @link https://github.com/fusioninventory/fusioninventory-for-gsit
- *
- */
-
-if (strpos(filter_input(INPUT_SERVER, "PHP_SELF"), "taskjobdeletetype.php")) {
- include ("../../../inc/includes.php");
- header("Content-Type: text/html; charset=UTF-8");
- Html::header_nocache();
-}
-
-Session::checkCentralAccess();
-
-$type = filter_input(INPUT_POST, "type");
-$taskjobs_id = filter_input(INPUT_POST, "taskjobs_id");
-
-if (is_null($type) || is_null($taskjobs_id) || !is_numeric($taskjobs_id)) {
- exit;
-}
-$taskjobs_id = intval($taskjobs_id);
-
-$item = filter_input(INPUT_POST, $type . 'item');
-
-if (is_null($item)) {
- exit;
-}
-
-$pfTaskjob = new PluginFusioninventoryTaskjob();
-$pfTaskjob->deleteitemtodefatc($type, $item, $taskjobs_id);
diff --git a/ajax/taskmethodupdate.php b/ajax/taskmethodupdate.php
deleted file mode 100644
index 3b1e982d7..000000000
--- a/ajax/taskmethodupdate.php
+++ /dev/null
@@ -1,66 +0,0 @@
-.
- *
- * ------------------------------------------------------------------------
- *
- * This file is called by ajax function and update task method.
- *
- * ------------------------------------------------------------------------
- *
- * @package FusionInventory
- * @author David Durieux
- * @copyright Copyright (c) 2010-2023 FusionInventory team
- * @license AGPL License 3.0 or (at your option) any later version
- * http://www.gnu.org/licenses/agpl-3.0-standalone.html
- * @link http://www.fusioninventory.org/
- * @link https://github.com/fusioninventory/fusioninventory-for-gsit
- *
- */
-
-if (strpos(filter_input(INPUT_SERVER, "PHP_SELF"), "taskmethodupdate.php")) {
- include ("../../../inc/includes.php");
- header("Content-Type: text/html; charset=UTF-8");
- Html::header_nocache();
-}
-
-Session::checkCentralAccess();
-
-$method = filter_input(INPUT_POST, "method");
-$taskjobs_id = filter_input(INPUT_POST, "taskjobs_id");
-
-if (is_null($method) || is_null($taskjobs_id) || !is_numeric($taskjobs_id)) {
- exit;
-}
-$taskjobs_id = intval($taskjobs_id);
-
-if ($method != '') {
- $pfTaskjob = new PluginFusioninventoryTaskjob();
- $pfTaskjob->updateMethod($method, $taskjobs_id);
-}
diff --git a/css/views.css b/css/views.css
index 40d8e3ea6..0850ea202 100644
--- a/css/views.css
+++ b/css/views.css
@@ -1000,3 +1000,11 @@ hr.criteriarule {
background-image: -ms-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
background-image: -o-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
}
+
+.clear_list {
+ cursor: pointer;
+}
+
+.delete_items_selected {
+ cursor: pointer;
+}
diff --git a/front/deploypackage.form.php b/front/deploypackage.form.php
index 76ed1003c..a9b03eb46 100644
--- a/front/deploypackage.form.php
+++ b/front/deploypackage.form.php
@@ -58,19 +58,128 @@
Html::back();
exit;
} else if (isset($_POST['add_item'])) {
- $data = array_map(['Toolbox', 'stripslashes_deep'],
- $package->escapeText($_POST));
- PluginFusioninventoryDeployPackage::alterJSON('add_item', $data);
+ $itemtype = filter_input(INPUT_POST, "itemtype");
+ if (is_null($itemtype) || $itemtype === false) {
+ Html::displayErrorAndDie("Error with wrong format of data sent");
+ }
+ $item = new stdClass();
+ $data = false;
+ switch ($itemtype) {
+ case 'PluginFusioninventoryDeployCheck':
+ $item = new PluginFusioninventoryDeployCheck();
+ $data = $item->check_data_from_form();
+ break;
+
+ case 'PluginFusioninventoryDeployFile':
+ $item = new PluginFusioninventoryDeployFile();
+ $data = $item->check_data_from_form();
+ break;
+
+ case 'PluginFusioninventoryDeployAction':
+ $item = new PluginFusioninventoryDeployAction();
+ $data = $item->check_data_from_form();
+ break;
+
+ case 'PluginFusioninventoryDeployUserinteraction':
+ $item = new PluginFusioninventoryDeployUserinteraction();
+ $data = $item->check_data_from_form();
+ break;
+
+ default:
+ Html::displayErrorAndDie("Error with wrong format of data sent");
+ }
+
+ if ($data === false) {
+ Html::displayErrorAndDie("Error with wrong format of data sent");
+ }
+ $item->add_item($data);
Html::back();
} else if (isset($_POST['save_item'])) {
- $data = array_map(['Toolbox', 'stripslashes_deep'],
- $package->escapeText($_POST));
- PluginFusioninventoryDeployPackage::alterJSON('save_item', $data);
+ $itemtype = filter_input(INPUT_POST, "itemtype");
+ if (is_null($itemtype) || $itemtype === false) {
+ Html::displayErrorAndDie("Error with wrong format of data sent");
+ }
+ $item = new stdClass();
+ $data = false;
+ switch ($itemtype) {
+ case 'PluginFusioninventoryDeployCheck':
+ $item = new PluginFusioninventoryDeployCheck();
+ $data = $item->check_data_from_form();
+ break;
+
+ case 'PluginFusioninventoryDeployFile':
+ $item = new PluginFusioninventoryDeployFile();
+ $data = $item->check_data_from_form();
+ break;
+
+ case 'PluginFusioninventoryDeployAction':
+ $item = new PluginFusioninventoryDeployAction();
+ $data = $item->check_data_from_form();
+ break;
+
+ case 'PluginFusioninventoryDeployUserinteraction':
+ $item = new PluginFusioninventoryDeployUserinteraction();
+ $data = $item->check_data_from_form();
+ break;
+
+ default:
+ Html::displayErrorAndDie("Error with wrong format of data sent");
+ }
+
+ if ($data === false) {
+ Html::displayErrorAndDie("Error with wrong format of data sent");
+ }
+ $item->save_item($data);
Html::back();
} else if (isset($_POST['remove_item'])) {
- $data = array_map(['Toolbox', 'stripslashes_deep'],
- $package->escapeText($_POST));
- PluginFusioninventoryDeployPackage::alterJSON('remove_item', $data);
+ $itemtype = filter_input(INPUT_POST, "itemtype");
+ if (is_null($itemtype) || $itemtype === false) {
+ Html::displayErrorAndDie("Error with wrong format of data sent");
+ }
+
+ $packages_id = filter_input(INPUT_POST, "packages_id");
+ if (
+ is_null($packages_id) || $packages_id === false ||
+ !is_numeric($packages_id) || intval($packages_id) === 0
+ ) {
+ Html::displayErrorAndDie("Error with wrong format of data sent");
+ }
+
+ $item = new stdClass();
+ $data = [
+ 'packages_id' => intval($packages_id)
+ ];
+ $varEntries = '';
+ switch ($itemtype) {
+ case 'PluginFusioninventoryDeployCheck':
+ $varEntries = 'checks_entries';
+ $item = new PluginFusioninventoryDeployCheck();
+ break;
+
+ case 'PluginFusioninventoryDeployFile':
+ $varEntries = 'actions_entries';
+ $item = new PluginFusioninventoryDeployFile();
+ break;
+
+ case 'PluginFusioninventoryDeployAction':
+ $varEntries = 'actions_entries';
+ $item = new PluginFusioninventoryDeployAction();
+ break;
+
+ case 'PluginFusioninventoryDeployUserinteraction':
+ $varEntries = 'userinteractions_entries';
+ $item = new PluginFusioninventoryDeployUserinteraction();
+ break;
+
+ default:
+ Html::displayErrorAndDie("Error with wrong format of data sent");
+ }
+
+ if (!isset($_POST[$varEntries]) || !is_array($_POST[$varEntries])) {
+ Html::displayErrorAndDie("Error with wrong format of data sent");
+ }
+ $data[$varEntries] = $_POST[$varEntries];
+ $item->remove_item($data);
Html::back();
}
diff --git a/inc/collectcontentcommon.class.php b/inc/collectcontentcommon.class.php
index 217ce831d..838367339 100644
--- a/inc/collectcontentcommon.class.php
+++ b/inc/collectcontentcommon.class.php
@@ -130,8 +130,8 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = false) {
}
$in = array_keys($a_colfiles);
$fk = getForeignKeyFieldForItemType($collect);
- if ($nb = countElementsInTable($this->getTable(),
- [$fk => $in]) > 0) {
+ $nb = countElementsInTable($this->getTable(), [$fk => $in]);
+ if ($nb > 0) {
return self::createTabEntry($collect::getTypeName(Session::getPluralNumber()), $nb);
}
}
diff --git a/inc/commonview.class.php b/inc/commonview.class.php
index 852c3454d..bf3cb3263 100644
--- a/inc/commonview.class.php
+++ b/inc/commonview.class.php
@@ -187,7 +187,7 @@ public function showCheckboxField($title, $varname, $options = []) {
* @param string $title
* @param string $itemtype a glpi/plugin itemtype
* @param mixed[] $options
- * @return string the rand number can be used with ajax to update something
+ * @return integer|boolean
*/
public function showDropdownForItemtype($title, $itemtype, $options = []) {
echo "";
diff --git a/inc/communication.class.php b/inc/communication.class.php
index 248fb8667..019559c2f 100644
--- a/inc/communication.class.php
+++ b/inc/communication.class.php
@@ -167,7 +167,7 @@ static function addLog($p_logs) {
/**
* Import and parse the XML sent by the agent
*
- * @param object $arrayinventory SimpleXMLElement
+ * @param mixed[] $arrayinventory
* @return boolean
*/
function import($arrayinventory) {
@@ -179,10 +179,9 @@ function import($arrayinventory) {
'Function import().'
);
- $this->message = $arrayinventory;
$errors = '';
- $xmltag = $this->message['QUERY'];
+ $xmltag = $arrayinventory['QUERY'];
if ($xmltag == "NETDISCOVERY") {
$xmltag = "NETWORKDISCOVERY";
}
@@ -192,7 +191,7 @@ function import($arrayinventory) {
}
if (!isset($_SESSION['plugin_fusioninventory_agents_id'])) {
- $agent = $pfAgent->infoByKey($this->message['DEVICEID']);
+ $agent = $pfAgent->infoByKey($arrayinventory['DEVICEID']);
} else {
$agent = ['id' => $_SESSION['plugin_fusioninventory_agents_id']];
}
@@ -200,33 +199,33 @@ function import($arrayinventory) {
return false;
}
- if (isset($this->message['CONTENT']['MODULEVERSION'])) {
+ if (isset($arrayinventory['CONTENT']['MODULEVERSION'])) {
$pfAgent->setAgentVersions($agent['id'],
$xmltag,
- $this->message['CONTENT']['MODULEVERSION']);
- } else if (isset($this->message['CONTENT']['VERSIONCLIENT'])) {
+ $arrayinventory['CONTENT']['MODULEVERSION']);
+ } else if (isset($arrayinventory['CONTENT']['VERSIONCLIENT'])) {
$version = str_replace("FusionInventory-Agent_",
"",
- $this->message['CONTENT']['VERSIONCLIENT']);
+ $arrayinventory['CONTENT']['VERSIONCLIENT']);
$pfAgent->setAgentVersions($agent['id'], $xmltag, $version);
}
- if (isset($this->message->CONTENT->MODULEVERSION)) {
+ if (isset($arrayinventory['CONTENT']['MODULEVERSION'])) {
$pfAgent->setAgentVersions($agent['id'],
$xmltag,
- (string)$this->message->CONTENT->MODULEVERSION);
- } else if (isset($this->message->CONTENT->VERSIONCLIENT)) {
+ (string)$arrayinventory['CONTENT']['MODULEVERSION']);
+ } else if (isset($arrayinventory['CONTENT']['VERSIONCLIENT'])) {
$version = str_replace("FusionInventory-Agent_",
"",
- (string)$this->message->CONTENT->VERSIONCLIENT);
+ (string)$arrayinventory['CONTENT']['VERSIONCLIENT']);
$pfAgent->setAgentVersions($agent['id'], $xmltag, $version);
}
if (isset($_SESSION['glpi_plugin_fusioninventory']['xmltags']["$xmltag"])) {
$moduleClass = $_SESSION['glpi_plugin_fusioninventory']['xmltags']["$xmltag"];
$moduleCommunication = new $moduleClass();
- $errors .= $moduleCommunication->import($this->message['DEVICEID'],
- $this->message['CONTENT'],
+ $moduleCommunication->import($arrayinventory['DEVICEID'],
+ $arrayinventory['CONTENT'],
$arrayinventory);
} else {
$errors.=__('Unattended element in', 'fusioninventory').' QUERY : *'.$xmltag."*\n";
diff --git a/inc/communicationnetworkdiscovery.class.php b/inc/communicationnetworkdiscovery.class.php
index ddb179923..95bbf4405 100644
--- a/inc/communicationnetworkdiscovery.class.php
+++ b/inc/communicationnetworkdiscovery.class.php
@@ -105,7 +105,7 @@ function import($p_DEVICEID, $a_CONTENT, $arrayinventory) {
if ($pfTaskjobstate->getFromDB($a_CONTENT['PROCESSNUMBER'])) {
if ($pfTaskjobstate->fields['state'] != PluginFusioninventoryTaskjobstate::FINISHED) {
$pfImportExport = new PluginFusioninventorySnmpmodelImportExport();
- $errors .= $pfImportExport->import_netdiscovery($a_CONTENT, $p_DEVICEID);
+ $pfImportExport->import_netdiscovery($a_CONTENT, $p_DEVICEID);
if (isset($a_CONTENT['AGENT']['END'])) {
$messages = [
'Total Found' => 0,
diff --git a/inc/computer.class.php b/inc/computer.class.php
index d131e2b7d..3484eb56b 100644
--- a/inc/computer.class.php
+++ b/inc/computer.class.php
@@ -76,7 +76,7 @@ function rawSearchOptions() {
'id' => 'fields_plugin',
'name' => __('Plugin fields')
];
- $fieldsoptions = plugin_fields_getAddSearchOptions('Computer');
+ $fieldsoptions = plugin_fields_getAddSearchOptions('Computer');
foreach ($fieldsoptions as $id=>$data) {
$data['id'] = $id;
$options[$id] = $data;
diff --git a/inc/config.class.php b/inc/config.class.php
index ba778b9dd..edbebed60 100644
--- a/inc/config.class.php
+++ b/inc/config.class.php
@@ -245,7 +245,7 @@ function defineTabs($options = []) {
*
* @param CommonGLPI $item the item object
* @param boolean $withtemplate true if is a template form
- * @return string|array name of the tab
+ * @return string name of the tab
*/
function getTabNameForItem(CommonGLPI $item, $withtemplate = false) {
if ($item->getType() == __CLASS__) {
diff --git a/inc/crontask.class.php b/inc/crontask.class.php
index 4dc2e91ed..fe7797b4e 100644
--- a/inc/crontask.class.php
+++ b/inc/crontask.class.php
@@ -123,8 +123,8 @@ static function getMenuContent() {
* @return string name of the tab
*/
function getTabNameForItem(CommonGLPI $item, $withtemplate = false) {
- if ($this->canView()) {
- $cnt = PluginFusioninventoryCrontask::countForItem($item);
+ if ($this->canView() && $item instanceof CommonDBTM) {
+ $cnt = PluginFusioninventoryCronTask::countForItem($item);
return self::createTabEntry(__('Cron tasks', 'fusioninventory'), $cnt);
}
return '';
diff --git a/inc/deployaction.class.php b/inc/deployaction.class.php
index c7be47904..60e8de86a 100644
--- a/inc/deployaction.class.php
+++ b/inc/deployaction.class.php
@@ -477,36 +477,105 @@ function removeLine(item) {
/**
- * Add a new item in actions of the package
- *
- * @param mixed[] $params list of fields with value of the action
- * @return boolean
+ * Clean data of package form
+ * @return array{'id': integer, 'actionstype': string, 'name': string, 'exec'?: string, 'retChecks'?: array{'type': string, 'values': (string|integer)[]}[], 'logLineLimit'?: int, 'from'?: string, 'to'?: string, 'list'?: string[]}|false
*/
- function add_item($params) {
- //prepare new action entry to insert in json
- $tmp = [];
- $fields = ['list', 'from', 'to', 'exec', 'name', 'logLineLimit'];
- foreach ($fields as $field) {
- if (isset($params[$field])) {
- $tmp[$field] = $params[$field];
- }
+ function check_data_from_form() {
+ $id = filter_input(INPUT_POST, "id");
+ $actionstype = filter_input(INPUT_POST, "actionstype");
+ $name = filter_input(INPUT_POST, "name");
+ // Optional, not present in all cases
+ $exec = filter_input(INPUT_POST, "exec");
+ $logLineLimit = filter_input(INPUT_POST, "logLineLimit");
+ $from = filter_input(INPUT_POST, "from");
+ $to = filter_input(INPUT_POST, "to");
+
+ if (
+ is_null($id) || $id === false || !is_numeric($id) ||
+ is_null($actionstype) || $actionstype === false ||
+ is_null($name) || $name === false
+ ) {
+ return false;
}
- //process ret checks
- if (isset($params['retchecks_type'])
- && !empty($params['retchecks_type'])) {
- foreach ($params['retchecks_type'] as $index => $type) {
- if ($type !== '0') {
- $tmp['retChecks'][] = [
- 'type' => $type,
- 'values' => [$params['retchecks_value'][$index]]
- ];
+ $data = [
+ 'id' => intval($id),
+ 'actionstype' => $actionstype,
+ 'name' => $name
+ ];
+
+ switch ($actionstype) {
+ case 'cmd':
+ if (is_null($exec) || $exec === false || !is_string($exec) || empty($exec)) {
+ return false;
}
- }
+ if (is_null($logLineLimit) || $exec === $logLineLimit) {
+ $logLineLimit = -1;
+ }
+ $data['exec'] = $exec;
+ $data['logLineLimit'] = intval($logLineLimit);
+ $data['retChecks'] = [];
+ if (
+ isset($_POST['retchecks_type']) && is_array($_POST['retchecks_type']) &&
+ isset($_POST['retchecks_value']) && is_array($_POST['retchecks_value']) &&
+ count($_POST['retchecks_type']) == count($_POST['retchecks_value'])
+ ) {
+ foreach ($_POST['retchecks_type'] as $index => $type) {
+ if ($type !== '0') {
+ if (!is_string($type) && !is_numeric($_POST['retchecks_value'][$index]) || !is_string($_POST['retchecks_value'][$index])) {
+ return false;
+ }
+ $data['retChecks'][] = [
+ 'type' => $type,
+ 'values' => [$_POST['retchecks_value'][$index]]
+ ];
+ }
+ }
+ }
+ break;
+
+ case 'move':
+ case 'copy':
+ if (is_null($from) || $from === false || !is_string($from) || empty($from)) {
+ return false;
+ }
+ if (is_null($to) || $to === false || !is_string($to) || empty($to)) {
+ return false;
+ }
+ $data['from'] = $from;
+ $data['to'] = $to;
+ break;
+
+ case 'mkdir':
+ case 'delete':
+ if (
+ !isset($_POST['list']) ||
+ !isset($_POST['list'][0]) ||
+ $_POST['list'][0] === false ||
+ !is_string($_POST['list'][0]) ||
+ empty($_POST['list'][0])
+ ) {
+ return false;
+ }
+ $data['list'] = [
+ $_POST['list'][0]
+ ];
+ break;
+
}
+ return $data;
+ }
+
+ /**
+ * Add a new item in actions of the package
+ *
+ * @param array{'id': integer, 'actionstype': string, 'name': string, 'exec'?: string, 'retChecks'?: array{'type': string, 'values': (string|integer)[]}[], 'logLineLimit'?: int, 'from'?: string, 'to'?: string, 'list'?: string[]} $params list of fields with value of the action
+ * @return boolean
+ */
+ function add_item($params) {
//append prepared data to new entry
- $new_entry[$params['actionstype']] = $tmp;
+ $new_entry[$params['actionstype']] = $params;
//get current order json
$data = json_decode($this->getJson($params['id']), true);
diff --git a/inc/deploycheck.class.php b/inc/deploycheck.class.php
index bd9f0d4e0..a1ac1f03d 100644
--- a/inc/deploycheck.class.php
+++ b/inc/deploycheck.class.php
@@ -470,7 +470,7 @@ function displayAjaxValues($config, $request_data, $rand, $mode) {
echo "