From 6cc74873b221cfbb455ab36c30da5144f13dd3f5 Mon Sep 17 00:00:00 2001
From: Erik Thuning <boooink@gmail.com>
Date: Wed, 15 Sep 2021 10:53:13 +0200
Subject: [PATCH] Fixed the last palces where ldap object must be passed

---
 include/Product.php    | 4 +++-
 include/SearchPage.php | 2 +-
 include/User.php       | 7 +++----
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/Product.php b/include/Product.php
index 7c0a0e6..9ea76ad 100644
--- a/include/Product.php
+++ b/include/Product.php
@@ -109,7 +109,9 @@ class Product {
         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) {
             $matchvalues = array();
             if(property_exists($this, $field)) {
diff --git a/include/SearchPage.php b/include/SearchPage.php
index e89111f..0eb095c 100644
--- a/include/SearchPage.php
+++ b/include/SearchPage.php
@@ -132,7 +132,7 @@ class SearchPage extends Page {
         $items = get_items($type);
         $out = array();
         foreach($items as $item) {
-            if($item->matches($terms)) {
+            if($item->matches($terms, $this->ldap)) {
                 $out[] = $item;
             }
         }
diff --git a/include/User.php b/include/User.php
index 658fea7..f2cbfe0 100644
--- a/include/User.php
+++ b/include/User.php
@@ -3,7 +3,6 @@ class User {
     private $id = 0;
     private $name = '';
     private $notes = '';
-    private $ldap = null;
     
     public static function create_user($name) {
         $ins_user = prepare('insert into `user`(`name`) values (?)');
@@ -45,17 +44,17 @@ class User {
         return true;
     }
 
-    public function matches($terms) {
+    public function matches($terms, $ldap) {
         foreach($terms as $field => $values) {
             $matchvalues = array();
             if($field == 'name') {
                 $matchvalues[] = $this->name;
-                $matchvalues[] = $this->get_displayname();
+                $matchvalues[] = $this->get_displayname($ldap);
             } else if(property_exists($this, $field)) {
                 $matchvalues[] = $this->$field;
             } else if($field == 'fritext') {
                 $matchvalues[] = $this->name;
-                $matchvalues[] = $this->get_displayname();
+                $matchvalues[] = $this->get_displayname($ldap);
                 $matchvalues[] = $this->notes;
             } else {
                 return false;