Code

Updated Placeholder handling, fixed problems with UPPER/lowercase handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 14 Jan 2011 16:03:08 +0000 (16:03 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 14 Jan 2011 16:03:08 +0000 (16:03 +0000)
Updated email address test for templates, it allows {} now, to be able to handle replacements.

git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.7@20596 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_plugin.inc
gosa-core/include/functions.inc
gosa-core/include/utils/class_tests.inc

index f932dd3f23b44e789e7d5cdebc636aae649fb29f..0180a8529a50fc25e108417911f1fecfdd84d9ad 100644 (file)
@@ -595,7 +595,7 @@ class plugin
     $this->attrs= $ldap->fetch();
 
     $values = array();
-    foreach($this->attributes as $name){
+    foreach(array('uid','sn','givenName') as $name){
         if(isset($this->parent->$name)){
             $value = $this->parent->$name;
             if(is_numeric($name)) continue;
index fde2df70e0fb1343eade77fd7793ef86b8647b42..22670325a322509c57f3c9a8fed9e99d8d96f171 100644 (file)
@@ -3717,11 +3717,14 @@ function fillReplacements($str, $attrs, $shellArg = FALSE, $default = "")
     }
     krsort($hits);
 
+    // Add lower case placeholders to avoid errors
+    foreach($attrs as $key => $attr) $attrs[strtolower($key)] = $attr;
+
     // Replace the placeholder in the given string now.
     foreach($hits as $match){
 
         // Avoid errors about undefined index.
-        $name = $match[2];
+        $name = strtolower($match[2]);
         if(!isset($attrs[$name])) $attrs[$name] = $default;
 
         // Calculate the replacement
index 602ce0623bf7666230bab6df4c52e62e7723e0a3..6b2e283a2ac6167972563a6e90d8c5cf24b75d7a 100644 (file)
@@ -205,7 +205,7 @@ class tests {
       return (TRUE);
     }
     if ($template){
-      return preg_match ("/^[._a-z0-9%\+-]+@[_a-z0-9-]+(\.[a-z0-9-]+)(\.[a-z0-9-]+)*$/i",
+      return preg_match ("/^[._a-z0-9{\[\]}%\+-]+@[_a-{}\[\]%z0-9-]+(\.[a-z0-9-]+)(\.[a-z0-9-]+)*$/i",
           $address);
     } else {
       return preg_match ("/^[._a-z0-9\+-]+@[_a-z0-9-]+(\.[a-z0-9i-]+)(\.[a-z0-9-]+)*$/i",