Code

Added new checks to prevent broken filter configs
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Mar 2010 10:20:35 +0000 (10:20 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Mar 2010 10:20:35 +0000 (10:20 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16373 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_management.inc
gosa-core/include/class_userFilter.inc
gosa-core/include/class_userFilterEditor.inc

index bd24cc5ec3b219e6b3293c61dad64452286be8d9..681d8381b17bf8002a3240eccdc1768ddaa17573 100644 (file)
@@ -182,6 +182,8 @@ class management
     if(userFilter::userFilteringAvailable()){
       $dummy = "<button type='submit' name='editFilter'>!!</button>";
       $this->registerAction("editFilter", "editFilter");
+
+      print_a(userFilter::getFilter());
     }
  
     // Display list
index bdb37df5d04ac0c96d2806083c873bc9629638db..5e34c36f1b5cd78467f28386effe7dd8a2628ba0 100644 (file)
@@ -203,7 +203,12 @@ class userFilter extends plugin
       for($i=0; $i < $attrs['gosaUserDefinedFilter']['count']; $i++){
         $tmp = userFilter::explodeFilterString($attrs['gosaUserDefinedFilter'][$i]);
         if(!isset($tmp['name'])) continue;
-           
+          
+        // Remove line breaks from the filter, which may were added for better reading. 
+        $c = preg_split('/\n/',$tmp['filter']);
+        foreach($c as $key => $str) $c[$key] = trim($str);
+        $tmp['filter'] = implode($c);
         // The filter is visible if it is shared or if is one of our own creations.
         //  ... and enabled.
         $visible = in_array('enable', $tmp['flags']) && 
index 5719106bb021058caeac5dcf09b843c73ed27668..ffff3e658b3c6fff057b338f7aa93225212a9806 100644 (file)
@@ -127,6 +127,14 @@ class userFilterEditor extends plugin
       $msgs[] = msgPool::invalid(_("Name"), $this->name,"/[a-z0-9\-_ ]/i");
     }  
 
+    // Count the number of opening and closing brackets - exclude escaped ones.
+    $f = preg_replace('/\\\\[\(\)]/',"",$this->filter);
+    $o = substr_count($f, '(');
+    $c = substr_count($f, ')');
+    if($o != $c){
+      $msgs[] = sprintf(_("Please check your filter, you have '%s' opening and '%s' closing brackets!"), $o, $c);
+    }
+
     return($msgs);
   }