Code

Fixed alphabet match
[gosa.git] / gosa-core / include / functions.inc
index 48bf1b87130c5f83763b4f82ae0f0cff25651520..d9a82de75ba20be2d811564f4e2ff67a9380bf0a 100644 (file)
@@ -309,14 +309,14 @@ function gosa_log ($message)
   global $ui;
 
   /* Preset to something reasonable */
-  $username= " unauthenticated";
+  $username= "[unauthenticated]";
 
   /* Replace username if object is present */
   if (isset($ui)){
     if ($ui->username != ""){
       $username= "[$ui->username]";
     } else {
-      $username= "unknown";
+      $username= "[unknown]";
     }
   }
 
@@ -1743,7 +1743,7 @@ function gen_uids($rule, $attributes)
       $size= preg_replace('/^.*{id(:|!)(\d+)}.*$/', '\\2', $uid);
 
       $start= $m[1]==":"?0:-1;
-      for ($i= $start, $p= pow(10,$size); $i < $p; $i++){
+      for ($i= $start, $p= pow(10,$size)-1; $i < $p; $i++){
         if ($i == -1) {
           $number= "";
         } else {
@@ -1757,6 +1757,9 @@ function gen_uids($rule, $attributes)
           break;
         }
       }
+
+      /* Remove link if nothing has been found */
+      $uid= preg_replace('/{id(:|!)\d+}/', '', $uid);
     }
 
     if(preg_match('/\{id#\d+}/',$uid)){
@@ -1772,6 +1775,9 @@ function gen_uids($rule, $attributes)
           break;
         }
       }
+
+      /* Remove link if nothing has been found */
+      $uid= preg_replace('/{id#\d+}/', '', $uid);
     }
 
     /* Don't assign used ones */
@@ -2926,7 +2932,7 @@ function get_next_id_pool($attrib) {
       msg_dialog::display(_("Error"), _("Cannot allocate a free ID:")." ".$ldap->get_error(), ERROR_DIALOG);
       return null;
     } else {
-      return $newAttr;
+      return $oldAttr;
     }
   }