Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ms users warning #1566

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/main_sections/ms_users/ms_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
$tab_options = $protectedPost;
$tab_options['form_name'] = $form_name;
echo open_form($form_name, '', '', 'form-horizontal');
$table_name = "TAB_ACCESSLVL" . $protectedPost['onglet'];
$table_name = "TAB_ACCESSLVL" . $protectedPost['onglet'] ?? '';

if (!isset($protectedPost['onglet']) || $protectedPost['onglet'] == "") {
$protectedPost['onglet'] = current($data_on);
Expand Down
8 changes: 4 additions & 4 deletions require/function_config_generale.php
Original file line number Diff line number Diff line change
Expand Up @@ -695,21 +695,21 @@ function pageGUI($advance) {

ligne('LOCAL_URI_SERVER', $l->g(565), 'radio', array('DEFAULT' => $l->g(823) . " (http://localhost:80/ocsinventory)", 'CUSTOM' => $l->g(822), 'VALUE' => $select_local_uri), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['LOCAL_URI_SERVER'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 254));
$def = VARLIB_DIR . '/download';
ligne('DOWNLOAD_PACK_DIR', $l->g(775), 'radio', array('DEFAULT' => $l->g(823) . " ($def)", 'CUSTOM' => $l->g(822), 'VALUE' => $select_pack), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['DOWNLOAD_PACK_DIR'], 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/download"));
ligne('DOWNLOAD_PACK_DIR', $l->g(775), 'radio', array('DEFAULT' => $l->g(823) . " ($def)", 'CUSTOM' => $l->g(822), 'VALUE' => $select_pack), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['DOWNLOAD_PACK_DIR'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/download"));

$def = VARLIB_DIR . '/ipd';
ligne('IPDISCOVER_IPD_DIR', $l->g(776), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_ipd), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['IPDISCOVER_IPD_DIR'], 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/ipd"));
ligne('IPDISCOVER_IPD_DIR', $l->g(776), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_ipd), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['IPDISCOVER_IPD_DIR'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/ipd"));

ligne('LOG_GUI', $l->g(824), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['LOG_GUI'] ?? 0));

$def = VARLOG_DIR . '/logs';
ligne('LOG_DIR', $l->g(825), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_log), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['LOG_DIR'], 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/logs"));
ligne('LOG_DIR', $l->g(825), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_log), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['LOG_DIR'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/logs"));

$def = VARLIB_DIR . '/tmp_dir';
ligne('TMP_DIR', $l->g(9611), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_tmp), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['TMP_DIR'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/tmp_dir"));

$def = VARLOG_DIR . '/scripts';
ligne('LOG_SCRIPT', $l->g(1254), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_scripts), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['LOG_SCRIPT'], 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/scripts"));
ligne('LOG_SCRIPT', $l->g(1254), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_scripts), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['LOG_SCRIPT'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/scripts"));

$def = ETC_DIR . '/' . MAIN_SECTIONS_DIR . 'conf/';
ligne('CONF_PROFILS_DIR', $l->g(1252), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_profils), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['CONF_PROFILS_DIR'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/conf"));
Expand Down
89 changes: 81 additions & 8 deletions require/search/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,26 @@ public function generateSearchQuery($sessData){
$columnName[$index] = $value['fields'];
$containvalue[$index] = $value['operator'];
}

$tabSessValue=[];
$tabSessComparator=[];
$tabSessOperator=[];
$maxSessValue=0;
$isLessOrMore=0;

// Retrieve all mutli search
foreach ($searchInfos as $val) {
$tabSessValue[] = $val[self::SESS_VALUES];
$tabSessComparator[] = $val[self::SESS_COMPARATOR];
$tabSessOperator[] = $val[self::SESS_OPERATOR];
$maxSessValue =max($tabSessValue);
}

// check if < or > operators exist once
foreach ($tabSessOperator as $val) {
if ($val == "LESS" || $val == "MORE") {
$isLessOrMore++;
}
}
foreach ($searchInfos as $value) {
$nameTable = $tableName;
$open="";
Expand Down Expand Up @@ -400,13 +419,67 @@ public function generateSearchQuery($sessData){
if($value[self::SESS_OPERATOR] != "IS NULL"){
if ($nameTable != DatabaseSearch::COMPUTER_DEF_TABLE && $nameTable != self::GROUP_TABLE && $value[self::SESS_FIELDS] != 'CATEGORY_ID' && $value[self::SESS_FIELDS] != 'CATEGORY'
&& $value[self::SESS_OPERATOR] != "NOT IN" && $value[self::SESS_OPERATOR] != "ISNOTEMPTY") {
$this->columnsQueryConditions .= "$operator[$p] $open EXISTS (SELECT 1 FROM %s WHERE hardware.ID = %s.HARDWARE_ID AND %s.%s %s '%s')$close ";
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $value[self::SESS_FIELDS];
$this->queryArgs[] = $value[self::SESS_OPERATOR];
$this->queryArgs[] = $value[self::SESS_VALUES];
$lessOperator = "<";

if ($isLessOrMore >0) {
if (($value[self::SESS_COMPARATOR] == "AND" || empty($value[self::SESS_COMPARATOR])) && ($value[self::SESS_COMPARATOR] != "OR" && in_array("AND", $tabSessComparator))) {
if ($maxSessValue == $value[self::SESS_VALUES]) {
$this->columnsQueryConditions .= "$operator[$p] $open EXISTS (SELECT 1 FROM %s WHERE hardware.ID = %s.HARDWARE_ID AND %s.%s %s %s) $close";
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $value[self::SESS_FIELDS];
$this->queryArgs[] = $value[self::SESS_OPERATOR];
$this->queryArgs[] = $value[self::SESS_VALUES];
} else {

if (array_shift($tabSessValue) == $maxSessValue) {
$this->columnsQueryConditions .= "$operator[$p] $open EXISTS (SELECT 1 FROM %s WHERE hardware.ID = %s.HARDWARE_ID AND %s.%s %s %s %s %s.%s %s %s $close";
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $value[self::SESS_FIELDS];
$this->queryArgs[] = $value[self::SESS_OPERATOR];
$this->queryArgs[] = $value[self::SESS_VALUES];
$this->queryArgs[] = $value[self::SESS_COMPARATOR];
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $value[self::SESS_FIELDS];
$this->queryArgs[] = $lessOperator;
$this->queryArgs[] = $maxSessValue;
$value[self::SESS_COMPARATOR] == "AND" ? $this->columnsQueryConditions .=")" : "";
} else {
$this->columnsQueryConditions .= "$operator[$p] $open EXISTS (SELECT 1 FROM %s WHERE hardware.ID = %s.HARDWARE_ID AND %s.%s %s %s AND %s.%s %s %s) $close";
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $value[self::SESS_FIELDS];
$this->queryArgs[] = $value[self::SESS_OPERATOR];
$this->queryArgs[] = $value[self::SESS_VALUES];
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $value[self::SESS_FIELDS];
$this->queryArgs[] = $lessOperator;
$this->queryArgs[] = $maxSessValue;
}
}
} elseif (($value[self::SESS_COMPARATOR] == "OR" || empty($value[self::SESS_COMPARATOR])) && ($value[self::SESS_COMPARATOR] != "AND" && in_array("OR", $tabSessComparator))) {
$value[self::SESS_COMPARATOR] == "OR" ? $this->columnsQueryConditions .=") " : "";
$this->columnsQueryConditions .= "$operator[$p] EXISTS (SELECT 1 FROM % WHERE hardware.ID = %s.HARDWARE_ID AND %s.%s %s %s $close";
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $value[self::SESS_FIELDS];
$this->queryArgs[] = $value[self::SESS_OPERATOR];
$this->queryArgs[] = $value[self::SESS_VALUES];
}
} else {
$this->columnsQueryConditions .= "$operator[$p] $open EXISTS (SELECT 1 FROM %s WHERE hardware.ID = %s.HARDWARE_ID AND %s.%s %s '%s')$close ";
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $nameTable;
$this->queryArgs[] = $value[self::SESS_FIELDS];
$this->queryArgs[] = $value[self::SESS_OPERATOR];
$this->queryArgs[] = $value[self::SESS_VALUES];
}
}elseif($nameTable == self::GROUP_TABLE || $value[self::SESS_FIELDS] == 'CATEGORY_ID' || $value[self::SESS_FIELDS] == 'CATEGORY'
|| $value[self::SESS_OPERATOR] == "NOT IN"){
$this->columnsQueryConditions .= "$operator[$p] $open EXISTS (SELECT 1 FROM %s WHERE hardware.ID = %s.HARDWARE_ID AND %s.%s %s (%s))$close ";
Expand Down
Loading