Skip to content

Commit

Permalink
fix(requesttype): force english for comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Oct 10, 2023
1 parent c4f799b commit 7b9e941
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions inc/field/requesttypefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,31 +173,63 @@ public function isValidValue($value): bool {
}

public function equals($value): bool {
global $TRANSLATE;

$oldLocale = $TRANSLATE->getLocale();
$TRANSLATE->setLocale("en_GB");
$_SESSION['glpilanguage'] = "en_GB";
$available = $this->getAvailableValues();
$TRANSLATE->setLocale($oldLocale);
$_SESSION['glpilanguage'] = $oldLocale;

if (!isset($available[$this->value])) {
return false;
}
return strcasecmp($available[$this->value], $value) === 0;
}

public function notEquals($value): bool {
global $TRANSLATE;

$oldLocale = $TRANSLATE->getLocale();
$TRANSLATE->setLocale("en_GB");
$_SESSION['glpilanguage'] = "en_GB";
$available = $this->getAvailableValues();
$TRANSLATE->setLocale($oldLocale);
$_SESSION['glpilanguage'] = $oldLocale;

if (!isset($available[$this->value])) {
return false;
}
return !$this->equals($value);
}

public function greaterThan($value): bool {
global $TRANSLATE;

$oldLocale = $TRANSLATE->getLocale();
$TRANSLATE->setLocale("en_GB");
$_SESSION['glpilanguage'] = "en_GB";
$available = $this->getAvailableValues();
$TRANSLATE->setLocale($oldLocale);
$_SESSION['glpilanguage'] = $oldLocale;

if (!isset($available[$this->value])) {
return false;
}
return strcasecmp($available[$this->value], $value) > 0;
}

public function lessThan($value): bool {
global $TRANSLATE;

$oldLocale = $TRANSLATE->getLocale();
$TRANSLATE->setLocale("en_GB");
$_SESSION['glpilanguage'] = "en_GB";
$available = $this->getAvailableValues();
$TRANSLATE->setLocale($oldLocale);
$_SESSION['glpilanguage'] = $oldLocale;

if (!isset($available[$this->value])) {
return false;
}
Expand Down

0 comments on commit 7b9e941

Please sign in to comment.