function prepareInputDataForProcess($input, $computers_id) { global $DBocs; $tables = $this->getTablesForQuery(); $fields = $this->getFieldsForQuery(); $rule_parameters = array(); $select_sql = ""; //Build the select request foreach ($fields as $field) { switch (utf8_strtoupper($field)) { //OCS server ID is provided by extra_params -> get the configuration associated with the ocs server case "OCS_SERVER": $rule_parameters["OCS_SERVER"] = $this->ocsservers_id; break; //TAG and DOMAIN should come from the OCS DB //TAG and DOMAIN should come from the OCS DB default: $select_sql .= ($select_sql != "" ? " , " : "") . $field; } } //Build the FROM part of the request //Remove all the non duplicated table names $from_sql = "FROM `hardware` "; foreach ($tables as $table => $linkfield) { if ($table != 'hardware' && !empty($linkfield)) { $from_sql .= " LEFT JOIN `{$table}` ON (`{$table}`.`{$linkfield}` = `hardware`.`ID`)"; } } if ($select_sql != "") { //Build the all request $sql = "SELECT {$select_sql}\n {$from_sql}\n WHERE `hardware`.`ID` = '{$computers_id}'"; OcsServer::checkOCSconnection($this->ocsservers_id); $result = $DBocs->query($sql); $ocs_datas = array(); $fields = $this->getFieldsForQuery(1); //May have more than one line : for example in case of multiple network cards if ($DBocs->numrows($result) > 0) { while ($datas = $DBocs->fetch_array($result)) { foreach ($fields as $field) { if ($field != "OCS_SERVER" && isset($datas[$field])) { $ocs_datas[$field][] = $datas[$field]; } } } } //This cas should never happend but... //Sometimes OCS can't find network ports but fill the right ip in hardware table... //So let's use the ip to proceed rules (if IP is a criteria of course) if (in_array("IPADDRESS", $fields) && !isset($ocs_datas['IPADDRESS'])) { $ocs_datas['IPADDRESS'] = OcsServer::getGeneralIpAddress($this->ocsservers_id, $computers_id); } return array_merge($rule_parameters, $ocs_datas); } return $rule_parameters; }