diff --git a/hook.php b/hook.php
index 8fc1bb50..01ba6ea6 100644
--- a/hook.php
+++ b/hook.php
@@ -108,7 +108,6 @@ function plugin_fields_install() {
* @return boolean
*/
function plugin_fields_uninstall() {
- global $DB;
if (!class_exists('PluginFieldsProfile')) {
Session::addMessageAfterRedirect(__("The plugin can't be uninstalled when the plugin is disabled", 'fields'),
@@ -219,8 +218,8 @@ function plugin_fields_MassiveActionsFieldsDisplay($options = []) {
*
* Actions for rules
* @since 0.84
- * @param $params input data
- * @return an array of actions
+ * @param array $params input data
+ * @return array an array of actions
*/
function plugin_fields_getRuleActions($params = []) {
$actions = [];
@@ -228,7 +227,7 @@ function plugin_fields_getRuleActions($params = []) {
switch ($params['rule_itemtype']) {
case "PluginFusioninventoryTaskpostactionRule":
$options = PluginFieldsContainer::getAddSearchOptions("Computer");
- foreach ($options as $num => $option) {
+ foreach ($options as $option) {
$actions[$option['linkfield']]['name'] = $option['name'];
$actions[$option['linkfield']]['type'] = $option['pfields_type'];
if ($option['pfields_type'] == 'dropdown') {
@@ -288,7 +287,6 @@ function plugin_fields_rule_matched($params = []) {
function plugin_fields_giveItem($itemtype, $ID, $data, $num) {
$searchopt = &Search::getOptions($itemtype);
$table = $searchopt[$ID]["table"];
- $field = $searchopt[$ID]["field"];
//fix glpi default Search::giveItem who for empty date display "--"
if (strpos($table, "glpi_plugin_fields") !== false
@@ -310,7 +308,7 @@ function plugin_datainjection_populate_fields() {
$container = new PluginFieldsContainer();
$found = $container->find(['is_active' => 1]);
- foreach ($found as $id => $values) {
+ foreach ($found as $values) {
$types = json_decode($values['itemtypes']);
foreach ($types as $type) {
diff --git a/inc/autoload.php b/inc/autoload.php
index 0cc5bc73..001bcefd 100644
--- a/inc/autoload.php
+++ b/inc/autoload.php
@@ -52,6 +52,7 @@ public function setOptions($options) {
}
public function processClassname($classname) {
+ $matches = [];
preg_match("/Plugin([A-Z][a-z0-9]+)([A-Z]\w+)/", $classname, $matches);
if (count($matches) < 3) {
diff --git a/inc/container.class.php b/inc/container.class.php
index b7ff8ad5..e35d3b75 100644
--- a/inc/container.class.php
+++ b/inc/container.class.php
@@ -253,8 +253,8 @@ static function uninstall() {
//uninstall container table and class
$obj = new self;
$containers = $obj->find();
- foreach ($containers as $containers_id => $container) {
- $obj->delete(['id' => $containers_id]);
+ foreach ($containers as $container) {
+ $obj->delete(['id' => $container['id']]);
}
//drop global container table
@@ -751,8 +751,6 @@ public function showForm($ID, $options = []) {
}
static function showFormItemtype($params = []) {
- global $CFG_GLPI;
-
$is_domtab = isset($params['type']) && $params['type'] == 'domtab';
$rand = $params['rand'];
@@ -800,7 +798,7 @@ static function showFormSubtype($params, $display = false) {
}
// For delete number :
- foreach ($tabs as $key => &$value) {
+ foreach ($tabs as &$value) {
$results = [];
if (preg_match_all('#(.+)#', $value, $results)) {
$value = str_replace($results[0][0], "", $value);
@@ -909,7 +907,7 @@ static function getEntries($type = 'tab', $full = false) {
$jsonitemtypes = json_decode($item['itemtypes']);
//show more info or not
- foreach ($jsonitemtypes as $k => $v) {
+ foreach ($jsonitemtypes as $v) {
if ($full) {
//check for translation
$item['itemtype'] = self::getType();
@@ -997,8 +995,6 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem
* @return boolean
*/
function updateFieldsValues($data, $itemtype, $massiveaction = false) {
- global $DB;
-
if (self::validateValues($data, $itemtype, $massiveaction) === false) {
return false;
}
@@ -1040,7 +1036,7 @@ function updateFieldsValues($data, $itemtype, $massiveaction = false) {
* @param string $itemtype item type
* @param array $data values send by update form
* @param array $old_values old values, if empty -> values add
- * @return nothing
+ * @return void
*/
static function constructHistory($containers_id, $items_id, $itemtype, $data,
$old_values = []) {
@@ -1165,7 +1161,7 @@ static function validateValues($data, $itemtype, $massiveaction) {
'plugin_fields_containers_id' => $data['plugin_fields_containers_id']
]);
- foreach ($fields as $fields_id => $field) {
+ foreach ($fields as $field) {
if (!$field['is_active']) {
continue;
}
diff --git a/inc/containerdisplaycondition.class.php b/inc/containerdisplaycondition.class.php
index 8a37943b..997d721c 100644
--- a/inc/containerdisplaycondition.class.php
+++ b/inc/containerdisplaycondition.class.php
@@ -308,7 +308,7 @@ public static function removeBlackListedOption($array, $itemtype_class){
$allowed_table = [getTableForItemType($itemtype_class), getTableForItemType(User::getType()), getTableForItemType(Group::getType())];
//use relation.constant.php to allow some tables (exclude Location which is managed later)
- foreach (getDbRelations() as $tablename => $relation) {
+ foreach (getDbRelations() as $relation) {
foreach ($relation as $main_table => $foreignKey) {
if($main_table == getTableForItemType($itemtype_class)
&& !is_array($foreignKey)
diff --git a/inc/field.class.php b/inc/field.class.php
index 7488bd26..db77d709 100644
--- a/inc/field.class.php
+++ b/inc/field.class.php
@@ -196,8 +196,6 @@ function prepareInputForAdd($input) {
}
function pre_deleteItem() {
- global $DB;
-
//remove field in container table
if ($this->fields['type'] !== "header"
&& !isset($_SESSION['uninstall_fields'])
@@ -299,7 +297,6 @@ function getNextRanking() {
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
if (!$withtemplate) {
- $nb = 0;
switch ($item->getType()) {
case __CLASS__ :
$ong[1] = $this->getTypeName(1);
@@ -332,9 +329,6 @@ function showSummary($container) {
$cID = $container->fields['id'];
// Display existing Fields
- $tmp = ['plugin_fields_containers_id' => $cID];
- $canadd = $this->can(-1, CREATE, $tmp);
-
$query = "SELECT `id`, `label`
FROM `".$this->getTable()."`
WHERE `plugin_fields_containers_id` = '$cID'
@@ -595,8 +589,6 @@ function ($itemtype) {
}
static function showForTabContainer($c_id, $items_id, $itemtype) {
- global $CFG_GLPI;
-
//profile restriction (for reading profile)
$profile = new PluginFieldsProfile;
$found = $profile->find(['profiles_id' => $_SESSION['glpiactiveprofile']['id'],
@@ -667,8 +659,6 @@ static private function showDomContainer($c_id, $itemtype, $items_id, $type = "d
* @return void
*/
static function showForTab($params) {
- global $CFG_GLPI;
-
$item = $params['item'];
$functions = array_column(debug_backtrace(), 'function');
diff --git a/inc/inventory.class.php b/inc/inventory.class.php
index fe4fd3ca..54fabfb9 100644
--- a/inc/inventory.class.php
+++ b/inc/inventory.class.php
@@ -37,7 +37,7 @@ static function updateInventory($params = []) {
&& isset($params['inventory_data']) && !empty($params['inventory_data'])) {
$availaibleItemType = ["Computer","Printer","NetworkEquipment"];
- foreach ($params['inventory_data'] as $itemtype => $inventories) {
+ foreach (array_keys($params['inventory_data']) as $itemtype) {
if (in_array($itemtype, $availaibleItemType)) {
//retrive items id switch itemtype
diff --git a/inc/labeltranslation.class.php b/inc/labeltranslation.class.php
index ece1f86b..410beefe 100644
--- a/inc/labeltranslation.class.php
+++ b/inc/labeltranslation.class.php
@@ -134,8 +134,6 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem
* @return void
**/
static function showTranslations(CommonDBTM $item) {
- global $DB, $CFG_GLPI;
-
$canedit = $item->can($item->getID(), UPDATE);
$rand = mt_rand();
if ($canedit) {
@@ -238,8 +236,6 @@ static function showTranslations(CommonDBTM $item) {
* @return void
*/
function showFormForItem($itemtype, $items_id, $id = -1) {
- global $CFG_GLPI;
-
if ($id > 0) {
$this->check($id, READ);
} else {
diff --git a/setup.php b/setup.php
index b72a6951..8302cf55 100644
--- a/setup.php
+++ b/setup.php
@@ -315,7 +315,7 @@ function plugin_fields_exportBlockAsYaml($container_id = null) {
$dropdown_obj = new $dropdown_itemtype();
$dropdown_datas = $dropdown_obj->find();
$datas = [];
- foreach ($dropdown_datas as $key => $value) {
+ foreach ($dropdown_datas as $value) {
$items = [];
$items['id'] = (int)$value['id'];
$items['value'] = $value['name'];