LSldap : Added combineFilters() method to combine two ldap filters
authorBenjamin Renard <brenard@easter-eggs.com>
Thu, 29 Oct 2009 22:17:30 +0000 (22:17 +0000)
committerBenjamin Renard <brenard@easter-eggs.com>
Thu, 29 Oct 2009 22:17:30 +0000 (22:17 +0000)
trunk/includes/class/class.LSldap.php

index 3935074..4db02c6 100644 (file)
@@ -407,6 +407,31 @@ class LSldap {
     }
     return true;
   }
+  
+  /**
+   * Combine LDAP Filters
+   * 
+   * @params array Array of LDAP filters
+   * 
+   * @retval Net_LDAP2_Filter | False The combined filter or False
+   **/
+  public static function combineFilters($op,$filters,$asStr=false) {
+    if (is_array($filters) && !empty($filters)) {
+      if (count($filters)==1) {
+        return $filters[0];
+      }
+      $filter=Net_LDAP2_Filter::combine($op,$filters);
+      if (!Net_LDAP2::isError($filter)) {
+        if ($asStr) {
+          return $filter->asString();
+        }
+        else {
+          return $filter;
+        }
+      }
+    }
+    return;
+  }
 }
 
 /*