From: hickert Date: Mon, 8 Jan 2007 07:04:55 +0000 (+0000) Subject: Skip remove server, if server has a still in use asterisk configuration. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=059b0ec8f78517d60662f4ea3ea690100a78fb1c;p=gosa.git Skip remove server, if server has a still in use asterisk configuration. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5472 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_servDB.inc b/plugins/admin/systems/class_servDB.inc index 127558005..4d99ad42e 100644 --- a/plugins/admin/systems/class_servDB.inc +++ b/plugins/admin/systems/class_servDB.inc @@ -38,7 +38,8 @@ class servdb extends plugin "goKrbAdmin", "goKrbPassword", "goFaxAdmin", "goFaxPassword", "goLogAdmin", "goLogPassword", "goFonAdmin", "goFonPassword", "goFonAreaCode", "goFonCountryCode","goGlpiAdmin","goGlpiDatabase","goGlpiPassword"); - var $objectclasses= array("top", "goServer"); + var $objectclasses = array("top", "goServer"); + var $init_objectclasses = array(); var $additionaloc= array("goImapServer" => array("goImapName", "goImapConnect", "goImapAdmin", "goImapPassword", "goImapSieveServer", @@ -62,6 +63,9 @@ class servdb extends plugin } } + /* Remember used databases */ + $this->init_objectclasses = $this->objectclasses; + /* We need to save the historical state of goImapName for later checking */ $this->goImapName_old= $this->goImapName; @@ -71,8 +75,8 @@ class servdb extends plugin function execute() { - /* Call parent execute */ - plugin::execute(); + /* Call parent execute */ + plugin::execute(); /* Fill templating stuff */ $smarty= get_smarty(); @@ -184,6 +188,33 @@ class servdb extends plugin } } } + + /* Check if we are able to remove the asterisk database. If the database is still in use skip */ + if (!in_array("goFonServer", $this->objectclasses) && in_array("goFonServer", $this->init_objectclasses)){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(goFonHomeServer=".$this->dn.")(|(uid=*)(cn=*)))",array("dn","uid","cn","goFonHomeServer")); + if($ldap->count()){ + + /* Number of entries shown in warning */ + $i = 3; + $str = ""; + while(($attrs = $ldap->fetch()) && $i >= 0){ + $i --; + if(isset($attrs['uid'][0])){ + $str .= $attrs['uid'][0]." "; + }else{ + $str .= $attrs['cn'][0]." "; + } + } + + /* Some entries found */ + if($i != 3){ + $message[] = sprintf(_("You can't remove the asterisk database extension, it is still in use by these objects '%s'."),trim($str)); + } + } + } + if (in_array("goImapServer", $this->objectclasses) && $this->goImapName != $this->goImapName_old) { // Attribute has changed @@ -254,6 +285,36 @@ class servdb extends plugin } } + function allow_remove() + { + /* Check if we are able to remove the asterisk database. If the database is still in use skip */ + if (in_array_ics("goFonServer", $this->init_objectclasses)){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(goFonHomeServer=".$this->dn.")(|(uid=*)(cn=*)))",array("dn","uid","cn","goFonHomeServer")); + if($ldap->count()){ + + /* Number of entries shown in warning */ + $i = 3; + $str = ""; + while(($attrs = $ldap->fetch()) && $i >= 0){ + $i --; + if(isset($attrs['uid'][0])){ + $str .= $attrs['uid'][0]." "; + }else{ + $str .= $attrs['cn'][0]." "; + } + } + + /* Some entries found */ + if($i != 3){ + return(sprintf(_("You can't remove the asterisk database extension, it is still in use by these objects '%s'."),trim($str))); + } + } + } + } + + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: