diff --git a/src/RuleCollection.php b/src/RuleCollection.php index 38a4fa5db31..d2fe47cd452 100644 --- a/src/RuleCollection.php +++ b/src/RuleCollection.php @@ -50,7 +50,7 @@ class RuleCollection extends CommonDBTM public $use_output_rule_process_as_next_input = false; /// Rule collection can be replay (for dictionary) public $can_replay_rules = false; - /// List of rules of the rule collection + /** @var SingletonRuleList $RuleList List of rules of the rule collection */ public $RuleList = null; /// Menu type public $menu_type = "rule"; @@ -1694,6 +1694,7 @@ public function showRulesEnginePreviewCriteriasForm($target, array $values, $con $input = $this->prepareInputDataForTestProcess($condition); if (count($input)) { + /** @var Rule $rule */ $rule = $this->getRuleClass(); $criterias = $rule->getAllCriteria(); echo "
"; @@ -1701,7 +1702,7 @@ public function showRulesEnginePreviewCriteriasForm($target, array $values, $con echo ""; echo "\n"; - //Brower all criterias + //Brower all criterias foreach ($input as $criteria) { echo ""; @@ -1953,7 +1954,11 @@ public function showRulesEnginePreviewResultsForm($target, array $input, $condit $output = $this->cleanTestOutputCriterias($output); unset($output["result"]); - $global_result = (count($output) ? 1 : 0); + if (count($output) === 1 && ($output['_no_rule_matches'] ?? false)) { + $global_result = 0; + } else { + $global_result = (count($output) ? 1 : 0); + } echo "
" . _n('Criterion', 'Criteria', Session::getPluralNumber()) . "
"; $this->showTestResults($rule, $output, $global_result); diff --git a/src/RuleRightCollection.php b/src/RuleRightCollection.php index 8eb7d8e1efc..283b25d850b 100644 --- a/src/RuleRightCollection.php +++ b/src/RuleRightCollection.php @@ -81,12 +81,10 @@ public function showTestResults($rule, array $output, $global_result) if (isset($output["_ldap_rules"]["rules_entities"])) { echo ""; echo ""; - foreach ($output["_ldap_rules"]["rules_entities"] as $entities) { - foreach ($entities as $entity) { - $this->displayActionByName("entity", $entity[0]); - if (isset($entity[1])) { - $this->displayActionByName("recursive", $entity[1]); - } + foreach ($output["_ldap_rules"]["rules_entities"] as $entity) { + $this->displayActionByName("entity", $entity[0]); + if (isset($entity[1])) { + $this->displayActionByName("recursive", $entity[1]); } } } @@ -232,23 +230,21 @@ public function prepareInputDataForProcess($input, $params) $params_lower = array_change_key_case($params, CASE_LOWER); //common parameters - $rule_parameters = [ + $rule_parameters = array_merge($params_lower, [ 'TYPE' => $params_lower["type"] ?? "", 'LOGIN' => $params_lower["login"] ?? "", 'MAIL_EMAIL' => $params_lower["email"] ?? $params_lower["mail_email"] ?? "", - '_groups_id' => $groups - ]; + ]); //IMAP/POP login method - if ($params_lower["type"] == Auth::MAIL) { + if ($rule_parameters["TYPE"] == Auth::MAIL) { $rule_parameters["MAIL_SERVER"] = $params_lower["mail_server"] ?? ""; } - //LDAP type method - if ($params_lower["type"] == Auth::LDAP) { - //Get all the field to retrieve to be able to process rule matching - $rule_fields = $this->getFieldsToLookFor(); - + //LDAP type method + //Get all the field to retrieve to be able to process rule matching + $rule_fields = $this->getFieldsToLookFor(); + if ($rule_parameters["TYPE"] == Auth::LDAP && count($rule_fields)) { //Get all the data we need from ldap to process the rules $sz = @ldap_read( $params_lower["connection"], diff --git a/src/SingletonRuleList.php b/src/SingletonRuleList.php index 89c3334c80c..1152354131f 100644 --- a/src/SingletonRuleList.php +++ b/src/SingletonRuleList.php @@ -35,7 +35,7 @@ class SingletonRuleList { - /// Items list + /** @var Rule[] $list Rule list */ public $list = []; /// Items loaded ? public $load = 0;
" . __('Entities assignment') . "