From: hickert Date: Wed, 10 Jan 2007 08:47:11 +0000 (+0000) Subject: Added allow_remove function for sub services. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c565e331b29220567936b591b003938e94102ed8;p=gosa.git Added allow_remove function for sub services. Added allow_remove for goFon service, if still in use abort remove git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5509 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_goFonServer.inc b/plugins/admin/systems/class_goFonServer.inc index d4cdf76b5..5f23e2162 100644 --- a/plugins/admin/systems/class_goFonServer.inc +++ b/plugins/admin/systems/class_goFonServer.inc @@ -85,7 +85,39 @@ class goFonServer extends goService{ plugin::save_object(); } } - + + + function allow_remove() + { + /* Check if we are able to remove the asterisk database. If the database is still in use skip */ + if($this->is_account){ + $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))); + } + } + } + return("fa"); + } + + /* Return plugin informations for acl handling */ function plInfo() { diff --git a/plugins/admin/systems/class_serverService.inc b/plugins/admin/systems/class_serverService.inc index c6fe5415b..c74c8489b 100644 --- a/plugins/admin/systems/class_serverService.inc +++ b/plugins/admin/systems/class_serverService.inc @@ -126,8 +126,17 @@ class ServerService extends plugin $tmp = $new_obj->getListEntry(); if($tmp['AllowRemove']){ - $this->plugins[$s_entry] = $new_obj; - $this->plugins[$s_entry]->is_account = false; + + /* Check if we are allowed to remove this service + */ + $str = $this->plugins[$s_entry]->allow_remove(); + + if(empty($str)){ + $this->plugins[$s_entry] = $new_obj; + $this->plugins[$s_entry]->is_account = false; + }else{ + print_red($str); + } } } @@ -391,6 +400,18 @@ class ServerService extends plugin } } } + + + /* Check if all plugins allow a remove .. */ + function allow_remove() + { + foreach($this->plugins as $name => $obj){ + $str = $obj->allow_remove(); + if(!empty($str)){ + return($str); + } + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: