From: hickert Date: Tue, 6 Oct 2009 06:40:35 +0000 (+0000) Subject: Do NOT allow to use phoneNumbers twice in gofon plugins. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d0e1874925e29ed5a6cb820796bd21d41eb3d467;p=gosa.git Do NOT allow to use phoneNumbers twice in gofon plugins. -May lead to invalid dialplan entries. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14530 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/gofon/gofon/phoneaccount/class_phoneAccount.inc b/gosa-plugins/gofon/gofon/phoneaccount/class_phoneAccount.inc index a250fa1dd..361eed980 100644 --- a/gosa-plugins/gofon/gofon/phoneaccount/class_phoneAccount.inc +++ b/gosa-plugins/gofon/gofon/phoneaccount/class_phoneAccount.inc @@ -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"))." 
". + 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){