/** * Show preview result of a rule * * @param $target where to go if action * @param $input input data array * @param $params params used (see addSpecificParamsForPreview) **/ function showRulePreviewResultsForm($target, $input, $params) { global $LANG; $actions = $this->getActions(); $check_results = array(); $output = array(); //Test all criterias, without stopping at the first good one $this->testCriterias($input, $check_results); //Process the rule $this->process($input, $output, $params, false); $criteria = new $this->rulecriteriaclass(); echo "<div class='spaced'>"; echo "<table class='tab_cadrehov'>"; echo "<tr><th colspan='4'>" . $LANG['rulesengine'][82] . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td class='center b'>" . $LANG['rulesengine'][16] . "</td>"; echo "<td class='center b'>" . $LANG['rulesengine'][14] . "</td>"; echo "<td class='center b'>" . $LANG['rulesengine'][15] . "</td>"; echo "<td class='center b'>" . $LANG['rulesengine'][41] . "</td>"; echo "</tr>\n"; foreach ($check_results as $ID => $criteria_result) { echo "<tr class='tab_bg_1'>"; $criteria->getFromDB($criteria_result["id"]); $this->showMinimalCriteria($criteria->fields); if ($criteria->fields['condition'] != self::PATTERN_FIND) { echo "<td class='b'>" . Dropdown::getYesNo($criteria_result["result"]) . "</td></tr>\n"; } else { echo "<td class='b'>" . DROPDOWN_EMPTY_VALUE . "</td></tr>\n"; } } echo "</table></div>"; $global_result = isset($output["_rule_process"]) ? 1 : 0; echo "<div class='spaced'>"; echo "<table class='tab_cadrehov'>"; echo "<tr><th colspan='2'>" . $LANG['rulesengine'][81] . "</th></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='center b' colspan='2'>" . $LANG['rulesengine'][41] . " : "; echo Dropdown::getYesNo($global_result) . "</td>"; $output = $this->preProcessPreviewResults($output); foreach ($output as $criteria => $value) { if (isset($actions[$criteria])) { echo "<tr class='tab_bg_2'>"; echo "<td>" . $actions[$criteria]["name"] . "</td>"; echo "<td>" . $this->getActionValue($criteria, $value) . "</td></tr>\n"; } } //If a regular expression was used, and matched, display the results if (count($this->regex_results)) { echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['rulesengine'][85] . "</td>"; echo "<td>"; printCleanArray($this->regex_results[0]); echo "</td></tr>\n"; } echo "</tr>\n"; echo "</table></div>"; }
/** * Clean Printing of and array in a table * * @param $tab the array to display * @param $pad Pad used * * @return nothing **/ function printCleanArray($tab, $pad = 0) { if (count($tab)) { echo "<table class='tab_cadre'>"; echo "<tr><th>KEY</th><th>=></th><th>VALUE</th></tr>"; foreach ($tab as $key => $val) { echo "<tr class='tab_bg_1'><td class='top right'>"; echo $key; echo "</td><td class='top'>=></td><td class='top tab_bg_1'>"; if (is_array($val)) { printCleanArray($val, $pad + 1); } else { echo $val; } echo "</td></tr>"; } echo "</table>"; } }
/** * Display information from LDAP server for user **/ private function showLdapDebug() { global $LANG; if ($this->fields['authtype'] != Auth::LDAP) { return false; } echo "<div class='spaced'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . $LANG['setup'][137] . ' - ' . $LANG['login'][2] . "</th></tr>"; echo "<tr class='tab_bg_2'><td>" . $LANG['ldap'][26] . " :</td>"; echo "<td>" . $this->fields['user_dn'] . "</td></tr>\n"; if ($this->fields['user_dn']) { echo "<tr class='tab_bg_2'><td>" . $LANG['title'][13] . " :</td><td>"; $config_ldap = new AuthLDAP(); $ds = false; if ($config_ldap->getFromDB($this->fields['auths_id'])) { $ds = $config_ldap->connect(); } if ($ds) { $info = AuthLdap::getUserByDn($ds, $this->fields['user_dn'], array('*', 'createTimeStamp', 'modifyTimestamp')); if (is_array($info)) { printCleanArray($info); } else { echo $LANG['stats'][2]; } } else { echo $LANG['log'][41]; } echo "</td></tr>\n"; } echo "</table></div>"; }