match is a keyword in php8, so renamed the match() function accordingly

This commit is contained in:
Erik Thuning 2024-02-21 11:37:35 +01:00
parent bd8e50493b
commit 048cfb3ee2
3 changed files with 12 additions and 12 deletions

@ -142,7 +142,7 @@ class Product extends Entity {
// If $key is a standard field, check against its value
$getter = $fields[$key];
$value = $this->$getter();
if(match($term, $value)) {
if(match_term($term, $value)) {
//Record a successful match
$matches[$key] = $value;
$matched = true;
@ -170,7 +170,7 @@ class Product extends Entity {
// First check basic fields
foreach($fields as $field => $getter) {
$value = $this->$getter();
if(match($term, $value)) {
if(match_term($term, $value)) {
$matches[$field] = $value;
$matched = true;
}
@ -189,7 +189,7 @@ class Product extends Entity {
}
// Then custom fields
foreach($this->get_info() as $field => $value) {
if(match($term, $value)) {
if(match_term($term, $value)) {
//Record a successful match
$matches[$field] = $value;
$matched = true;
@ -202,7 +202,7 @@ class Product extends Entity {
if(isset($info[$key])) {
// If $key is a valid custom field on this product
$value = $info[$key];
if(match($term, $value)) {
if(match_term($term, $value)) {
//Record a successful match
$matches[$key] = $value;
$matched = true;
@ -228,7 +228,7 @@ class Product extends Entity {
$tags = $this->get_tags();
$matches = array();
foreach($tags as $tag) {
if(match($term, $tag)) {
if(match_term($term, $tag)) {
$matches[] = $tag;
}
}

@ -55,12 +55,12 @@ class User extends Entity {
case 'name':
// If the key is name, check username and displayname
$name = $this->get_name();
if(match($term, $name)) {
if(match_term($term, $name)) {
$matches['name'] = $name;
$matched = true;
}
$dname = $this->get_displayname($ldap);
if(match($term, $dname)) {
if(match_term($term, $dname)) {
$matches['displayname'] = $dname;
$matched = true;
}
@ -68,14 +68,14 @@ class User extends Entity {
case 'note':
// If the key is note, check it.
$note = $this->get_note();
if($note && match($term, $note)) {
if($note && match_term($term, $note)) {
$matches['note'] = $note;
$matched = true;
}
break;
case 'email':
$email = $this->get_email($ldap, false);
if($email && match($term, $email)) {
if($email && match_term($term, $email)) {
$matches['email'] = $email;
$matched = true;
}
@ -83,12 +83,12 @@ class User extends Entity {
case 'fritext':
//Check everything if the key is fritext
$name = $this->get_name();
if(match($term, $name)) {
if(match_term($term, $name)) {
$matches['name'] = $name;
$matched = true;
}
$dname = $this->get_displayname($ldap);
if(match($term, $dname)) {
if(match_term($term, $dname)) {
$matches['displayname'] = $dname;
$matched = true;
}

@ -253,7 +253,7 @@ function suggest_content($fieldname) {
return $out;
}
function match($term, $subject) {
function match_term($term, $subject) {
if(fnmatch('*'.$term->get_query().'*', $subject, FNM_CASEFOLD)) {
return true;
}