Code

Updated class_acl.inc
[gosa.git] / gosa-core / include / class_filter.inc
index 3dca983e0da73e86e7cd05643ff0a02bb567bb50..0bea6c4a69439e0d332efb044255762bf63b26fa 100644 (file)
@@ -1,4 +1,24 @@
 <?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id$$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 
 class filter {
 
@@ -103,6 +123,17 @@ class filter {
           $this->alphabetElements[]= $tag;
         }
       }
+
+      // Sort elements for element length to allow proper replacing later on
+      function strlenSort($a, $b) {
+        if (strlen($a['tag']) == strlen($b['tag'])) {
+          return 0;
+        }
+       return (strlen($a['tag']) < strlen($b['tag']) ? -1 : 1);
+      } 
+      uasort($this->elements, 'strlenSort');
+      $this->elements= array_reverse($this->elements);
+
     }
 
     return true;  
@@ -112,7 +143,15 @@ class filter {
   function getTextfield($element)
   {
     $tag= $element['tag'];
-    $result= "<input class='filter_textfield' id='$tag' name='$tag' type='text' size='30' maxlength='30' value='".$this->elementValues[$tag]."'>";
+    $size= 30;
+    if (isset($element['size'])){
+      $size= $element['size'];
+    }
+    $maxlength= 30;
+    if (isset($element['maxlength'])){
+      $maxlength= $element['maxlength'];
+    }
+    $result= "<input class='filter_textfield' id='$tag' name='$tag' type='text' size='$size' maxlength='maxlength' value='".$this->elementValues[$tag]."'>";
     if (isset($element['autocomplete'])) {
       $frequency= "0.5";
       $characters= "1";
@@ -389,12 +428,13 @@ class filter {
           $this->elementValues[$tag]= "";
         }
       }
-    }
 
-    // Save scope if needed
-    if ($this->scopeMode == "auto") {
-      $this->scope= isset($_POST['SCOPE'])?"sub":"one";
+      // Save scope if needed
+      if ($this->scopeMode == "auto") {
+        $this->scope= isset($_POST['SCOPE'])?"sub":"one";
+      }
     }
+
   }