Fixed the last palces where ldap object must be passed

This commit is contained in:
Erik Thuning 2021-09-15 10:53:13 +02:00
parent 3c8a0485de
commit 6cc74873b2
3 changed files with 7 additions and 6 deletions

@ -109,7 +109,9 @@ class Product {
return true; return true;
} }
public function matches($terms) { // Ldap object must be passed to keep the arglist in sync
// with User->matches()
public function matches($terms, $ldap) {
foreach($terms as $field => $values) { foreach($terms as $field => $values) {
$matchvalues = array(); $matchvalues = array();
if(property_exists($this, $field)) { if(property_exists($this, $field)) {

@ -132,7 +132,7 @@ class SearchPage extends Page {
$items = get_items($type); $items = get_items($type);
$out = array(); $out = array();
foreach($items as $item) { foreach($items as $item) {
if($item->matches($terms)) { if($item->matches($terms, $this->ldap)) {
$out[] = $item; $out[] = $item;
} }
} }

@ -3,7 +3,6 @@ class User {
private $id = 0; private $id = 0;
private $name = ''; private $name = '';
private $notes = ''; private $notes = '';
private $ldap = null;
public static function create_user($name) { public static function create_user($name) {
$ins_user = prepare('insert into `user`(`name`) values (?)'); $ins_user = prepare('insert into `user`(`name`) values (?)');
@ -45,17 +44,17 @@ class User {
return true; return true;
} }
public function matches($terms) { public function matches($terms, $ldap) {
foreach($terms as $field => $values) { foreach($terms as $field => $values) {
$matchvalues = array(); $matchvalues = array();
if($field == 'name') { if($field == 'name') {
$matchvalues[] = $this->name; $matchvalues[] = $this->name;
$matchvalues[] = $this->get_displayname(); $matchvalues[] = $this->get_displayname($ldap);
} else if(property_exists($this, $field)) { } else if(property_exists($this, $field)) {
$matchvalues[] = $this->$field; $matchvalues[] = $this->$field;
} else if($field == 'fritext') { } else if($field == 'fritext') {
$matchvalues[] = $this->name; $matchvalues[] = $this->name;
$matchvalues[] = $this->get_displayname(); $matchvalues[] = $this->get_displayname($ldap);
$matchvalues[] = $this->notes; $matchvalues[] = $this->notes;
} else { } else {
return false; return false;