Code

Do NOT allow to use phoneNumbers twice in gofon plugins.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 6 Oct 2009 06:40:35 +0000 (06:40 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 6 Oct 2009 06:40:35 +0000 (06:40 +0000)
-May lead to invalid dialplan entries.

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

gosa-plugins/gofon/gofon/phoneaccount/class_phoneAccount.inc

index a250fa1dd0ed4d65761c52839120c06cbf0804ea..361eed9804a6b74b8e433ad008a852726ffe284a 100644 (file)
@@ -1437,6 +1437,27 @@ class phoneAccount extends plugin
       $message[]= msgPool::required("Phone number");
     }
 
+    /* Do not allow to save duplicate phone numbers 
+     *  this may destroy the extensions table.
+     */ 
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);  
+    $numberFilter = "";
+    foreach($this->phoneNumbers as $number){
+      $numberFilter .= "(telephoneNumber={$number})";
+    }
+    $ldap->search("(&(!(uid=".$this->uid."))(objectClass=goFonAccount)(|{$numberFilter}))",array("dn","telephoneNumber"));
+    $res = array();
+    while($attrs = $ldap->fetch()){
+      unset($attrs['telephoneNumber']['count']);
+      $res = array_merge($res,array_intersect($attrs['telephoneNumber'], $this->phoneNumbers));
+    }
+    $res = array_unique($res);
+    if(count($res)){
+      $message[] = msgPool::duplicated(_("Phone number"))."&nbsp;<br>".
+        implode(array_intersect($res, $this->phoneNumbers), ", ");
+    }
+
     /* check for ! in any parameter setting*/
     if(isset($this->macroarray[$this->macro])){
       foreach($this->macroarray[$this->macro] as $val){