From aecf252118426dc28d7ed82927c8dc33e906f7ec Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Fri, 15 Jun 2018 17:21:26 +0200 Subject: [PATCH] FEAT #7836 Php7.2 --- apps/maarch_entreprise/actions/index_mlb.php | 5 ++- .../class/class_lists_Abstract.php | 15 +++++---- .../definition_mail_categories.php | 2 +- core/class/ObjectControlerAbstract.php | 2 +- core/class/class_functions.php | 8 +++-- core/class/class_history.php | 6 ++-- .../class/class_manage_listdiff_Abstract.php | 32 +++++++++++++++---- modules/entities/difflist_display.php | 6 ++-- modules/notes/notes.php | 4 +-- .../class/events_controler_Abstract.php | 3 +- src/app/action/models/ActionModelAbstract.php | 14 ++++---- 11 files changed, 63 insertions(+), 34 deletions(-) diff --git a/apps/maarch_entreprise/actions/index_mlb.php b/apps/maarch_entreprise/actions/index_mlb.php index 2dbad630aed..1a152c6a932 100755 --- a/apps/maarch_entreprise/actions/index_mlb.php +++ b/apps/maarch_entreprise/actions/index_mlb.php @@ -108,7 +108,10 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $c $allEntitiesTree = array(); $EntitiesIdExclusion = array(); - if (count($_SESSION['user']['redirect_groupbasket'][$_SESSION['current_basket']['id']][$actionId]['entities']) > 0) { + if (!empty($_SESSION['user']['redirect_groupbasket'][$_SESSION['current_basket']['id']][$actionId]['entities']) && + is_array($_SESSION['user']['redirect_groupbasket'][$_SESSION['current_basket']['id']][$actionId]['entities']) && + count($_SESSION['user']['redirect_groupbasket'][$_SESSION['current_basket']['id']][$actionId]['entities']) > 0) + { $stmt = $db->query( 'SELECT entity_id FROM ' .ENT_ENTITIES.' WHERE entity_id not in (' diff --git a/apps/maarch_entreprise/class/class_lists_Abstract.php b/apps/maarch_entreprise/class/class_lists_Abstract.php index f31e08ce08e..a2bc5aefc2e 100755 --- a/apps/maarch_entreprise/class/class_lists_Abstract.php +++ b/apps/maarch_entreprise/class/class_lists_Abstract.php @@ -3037,7 +3037,7 @@ abstract class lists_Abstract extends Database { $actionsList = ''; $actionsList .= ' <p align="center">'; - if (count($this->params['actions']) > 0) { + if (!empty($this->params['actions']) && is_array($this->params['actions']) && count($this->params['actions']) > 0) { $actionsList .= ' <b>'._ACTIONS.' :</b>'; $actionsList .= ' <select name="action" id="action">'; $actionsList .= ' <option value="">'._CHOOSE_ACTION.'</option>'; @@ -3204,6 +3204,9 @@ abstract class lists_Abstract extends Database protected function _checkTypeOfActionIcon($actionButtons, $type) { $isThisType = false; + if (empty($actionButtons) || !is_array($actionButtons)) { + return false; + } for ($button = 0; $button < count($actionButtons); ++$button) { if ($actionButtons[$button]['type'] == $type) { $isThisType = true; @@ -3614,12 +3617,10 @@ abstract class lists_Abstract extends Database if (count($resultArray) > 0 || $this->params['bool_showAddButton']) { //Need a form? $this->withForm = false; - if ( - $this->params['bool_checkBox'] === true || - $this->params['bool_radioButton'] === true || - count($parameters['actions'] > 0) || - count($parameters['buttons'] > 0) || - !empty($parameters['defaultAction']) + if ($this->params['bool_checkBox'] === true || $this->params['bool_radioButton'] === true || + (!empty($parameters['actions']) && is_array($parameters['actions']) && count($parameters['actions'] > 0)) || + (!empty($parameters['buttons']) && is_array($parameters['buttons']) && count($parameters['buttons'] > 0)) + || !empty($parameters['defaultAction']) ) { //Need a form! $this->withForm = true; diff --git a/apps/maarch_entreprise/definition_mail_categories.php b/apps/maarch_entreprise/definition_mail_categories.php index 8a89089c691..4c4a2863c80 100644 --- a/apps/maarch_entreprise/definition_mail_categories.php +++ b/apps/maarch_entreprise/definition_mail_categories.php @@ -576,7 +576,7 @@ $_ENV['categories']['ged_doc']['subject'] = array( $_ENV['categories']['ged_doc']['type_contact'] = array( 'type_form' => 'radio', 'mandatory' => true, - 'label' => _AUTHOR_TYPE, + 'label' => 'type de contact', 'table' => 'none', 'values' => array( 'internal', diff --git a/core/class/ObjectControlerAbstract.php b/core/class/ObjectControlerAbstract.php index 2122ef9e289..c779c42e427 100755 --- a/core/class/ObjectControlerAbstract.php +++ b/core/class/ObjectControlerAbstract.php @@ -300,7 +300,7 @@ abstract class ObjectControler //$theQuery = "SELECT * FROM $table_name WHERE $table_id = :id " . $whereComp; $queryParams = array(':id' => $id); - if (count($params > 0)) { + if (!empty($params) && is_array($params) && count($params > 0)) { foreach ($params as $keyParam => $keyValue) { $queryParams[":" . $keyParam] = $keyValue; } diff --git a/core/class/class_functions.php b/core/class/class_functions.php index 893bd73485e..094f6906a1c 100755 --- a/core/class/class_functions.php +++ b/core/class/class_functions.php @@ -935,9 +935,11 @@ class functions $to_del = array("\t", "\n", "�A;", "�D;", "\r"); $string = str_replace($to_del, ' ', $string); } - for($i=0;$i<count($chars_to_escape);$i++) - { - $string = str_replace($chars_to_escape[$i], '\\'.$chars_to_escape, $string); + if (!empty($chars_to_escape) && is_array($chars_to_escape)) { + for($i=0;$i<count($chars_to_escape);$i++) + { + $string = str_replace($chars_to_escape[$i], '\\'.$chars_to_escape, $string); + } } if ($escape_quote) { diff --git a/core/class/class_history.php b/core/class/class_history.php index a96e71c4d44..4612a623c7f 100755 --- a/core/class/class_history.php +++ b/core/class/class_history.php @@ -100,8 +100,8 @@ class history $databasetype, $id_module = 'admin', $isTech = false, - $result = _OK, - $level = _LEVEL_DEBUG, + $result = 'ok', + $level = 'DEBUG', $user = '' ) { $db = new Database(); @@ -361,7 +361,7 @@ class history switch ($level) { - case _LEVEL_DEBUG: + case 'DEBUG': $logger->debug( $logLine ); diff --git a/modules/entities/class/class_manage_listdiff_Abstract.php b/modules/entities/class/class_manage_listdiff_Abstract.php index 41e2ac6b58f..799fc49c869 100755 --- a/modules/entities/class/class_manage_listdiff_Abstract.php +++ b/modules/entities/class/class_manage_listdiff_Abstract.php @@ -221,7 +221,11 @@ abstract class diffusion_list_Abstract extends functions // users //********************************************************************** - for ($i = 0, $l = count($diffList[$role_id]['users']); + $l = 0; + if (!empty($difflist[$role_id]['users']) && is_array($difflist[$role_id]['users'])) { + $l = count($diffList[$role_id]['users']); + } + for ($i = 0; $i < $l; ++$i ) { @@ -245,7 +249,11 @@ abstract class diffusion_list_Abstract extends functions } // Entities //********************************************************************** - for ($i = 0, $l = count($diffList[$role_id]['entities']); $i < $l; ++$i) { + $l = 0; + if (!empty($difflist[$role_id]['entities']) && is_array($difflist[$role_id]['entities'])) { + $l = count($diffList[$role_id]['entities']); + } + for ($i = 0; $i < $l; ++$i) { $entity = $diffList[$role_id]['entities'][$i]; //print_r($description); exit; $stmt = $db->query( @@ -417,7 +425,10 @@ abstract class diffusion_list_Abstract extends functions $item_mode = $role_id; } - $cptUsers = count($diffList[$role_id]['users']); + $cptUsers = 0; + if (!empty($difflist[$role_id]['users']) && is_array($difflist[$role_id]['users'])) { + $cptUsers = count($diffList[$role_id]['users']); + } for ($i = 0; $i < $cptUsers; ++$i) { $userFound = false; $userId = trim($diffList[$role_id]['users'][$i]['user_id']); @@ -429,7 +440,10 @@ abstract class diffusion_list_Abstract extends functions $signatory = ($diffList[$role_id]['users'][$i]['signatory'] ? 'true' : 'false'); $requested_signature = ($diffList[$role_id]['users'][$i]['requested_signature'] ? 'true' : 'false'); - $cptOldUsers = count($oldListInst[$role_id]['users']); + $cptOldUsers = 0; + if (!empty($oldListInst[$role_id]['users']) && is_array($oldListInst[$role_id]['users'])) { + $cptOldUsers = count($oldListInst[$role_id]['users']); + } for ($h = 0; $h < $cptOldUsers; ++$h) { if ($userId == $oldListInst[$role_id]['users'][$h]['user_id']) { $userFound = true; @@ -500,13 +514,19 @@ abstract class diffusion_list_Abstract extends functions } //CUSTOM ENTITY ROLES - $cptEntities = count($diffList[$role_id]['entities']); + $cptEntities = 0; + if (!empty($difflist[$role_id]['entities']) && is_array($difflist[$role_id]['entities'])) { + $cptEntities = count($diffList[$role_id]['entities']); + } for ($j = 0; $j < $cptEntities; ++$j) { $entityFound = false; $entityId = trim($diffList[$role_id]['entities'][$j]['entity_id']); $visible = $diffList[$role_id]['entities'][$j]['visible']; $viewed = (int) $diffList[$role_id]['entities'][$j]['viewed']; - $cptOldEntities = count($oldListInst[$role_id]['entities']); + $cptOldEntities = 0; + if (is_array($oldListInst[$role_id]['entities'])) { + $cptOldEntities = count($oldListInst[$role_id]['entities']); + } for ($g = 0; $g < $cptOldEntities; ++$g) { if ($entityId == $oldListInst[$role_id]['entities'][$g]['entity_id']) { $entityFound = true; diff --git a/modules/entities/difflist_display.php b/modules/entities/difflist_display.php index eb4e8887d3b..8d618f8611e 100755 --- a/modules/entities/difflist_display.php +++ b/modules/entities/difflist_display.php @@ -24,8 +24,8 @@ foreach ($roles as $role_id => $role_label) { if (($specific_role != $role_id && $specific_role.'_copy' != $role_id && $specific_role.'_info' != $role_id) && isset($specific_role) && $specific_role != '') { continue; } - if (count($difflist[$role_id]['users']) > 0 - || count($difflist[$role_id]['entities']) > 0 + if ((!empty($difflist[$role_id]['users']) && is_array($difflist[$role_id]['users']) && count($difflist[$role_id]['users']) > 0) + || (!empty($difflist[$role_id]['users']) && is_array($difflist[$role_id]['users']) && count($difflist[$role_id]['entities']) > 0) ) { ++$empty; $contentDiffList .= '<h3 class="sstit" style="font-size: 1.2em;">'.$role_label.'</h3>'; @@ -76,7 +76,7 @@ foreach ($roles as $role_id => $role_label) { } $contentDiffList .= '</table>'; } - if (count($difflist[$role_id]['entities']) > 0) { + if (!empty($difflist[$role_id]['entities']) && is_array($difflist[$role_id]['entities']) && count($difflist[$role_id]['entities']) > 0) { $contentDiffList .= '<table cellpadding="0" cellspacing="0" border="0" class="listingsmall liste_diff spec" style="width:100%;margin:0;">'; $color = ' class="col"'; diff --git a/modules/notes/notes.php b/modules/notes/notes.php index a690046f3c3..fc4f9426d0b 100755 --- a/modules/notes/notes.php +++ b/modules/notes/notes.php @@ -287,7 +287,7 @@ if (isset($_REQUEST['load'])) { . "index.php?display=true&module=notes&page=notes_ajax_content" . "&mode=add&identifier=".$identifier."&origin=".$origin . $parameters."')", - "icon" => 'pencil', + "icon" => 'pencil-alt', "tooltip" => _ADD_NOTE, "alwaysVisible" => true ); @@ -302,7 +302,7 @@ if (isset($_REQUEST['load'])) { ."&mode=up&id=@@id@@&identifier=".$identifier."&origin=".$origin . $parameters."');", "class" => "read", - "icon" => "pencil", + "icon" => "pencil-alt", // "label" => _UPDATE.'/'._DELETE, "tooltip" => _UPDATE.'/'._DELETION, "disabledRules" => "@@user_id@@ != '".$_SESSION['user']['UserId']."'" diff --git a/modules/notifications/class/events_controler_Abstract.php b/modules/notifications/class/events_controler_Abstract.php index 098904ea509..45d0459f313 100755 --- a/modules/notifications/class/events_controler_Abstract.php +++ b/modules/notifications/class/events_controler_Abstract.php @@ -87,7 +87,8 @@ abstract class events_controler_Abstract extends ObjectControler $notifications[] = $notification; } } - if (count($notifications) == 0) return; + if (empty($notifications) || !is_array($notifications) || count($notifications) == 0) + return; foreach ($notifications as $notification) { $dbConn->query( "INSERT INTO " diff --git a/src/app/action/models/ActionModelAbstract.php b/src/app/action/models/ActionModelAbstract.php index 5696edc70bc..25f0cb07ae0 100644 --- a/src/app/action/models/ActionModelAbstract.php +++ b/src/app/action/models/ActionModelAbstract.php @@ -112,12 +112,14 @@ abstract class ActionModelAbstract $tab['action_id'] = $aArgs['id']; - for ($i=0; $i < count($aArgs['actionCategories']); $i++) { - $tab['category_id'] = $aArgs['actionCategories'][$i]; - DatabaseModel::insert([ - 'table' => 'actions_categories', - 'columnsValues' => $tab - ]); + if (!empty($aArgs['actionCategories'])) { + foreach ($aArgs['actionCategories'] as $actionCategory) { + $tab['category_id'] = $actionCategory; + DatabaseModel::insert([ + 'table' => 'actions_categories', + 'columnsValues' => $tab + ]); + } } return true; -- GitLab