From 31e5dc911741a33f7dff3ee714a39266383c5093 Mon Sep 17 00:00:00 2001 From: psc Date: Wed, 27 May 2009 09:51:54 +0000 Subject: [PATCH] Add a allow_remove function to the goService class to disallow removal of systems, when it provides services that are in use. (Trac: #2638) git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13670 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/services/class_goService.inc | 23 +++++++++++++++++++ .../systems/locale/de/LC_MESSAGES/messages.po | 4 ++++ trunk/gosa-plugins/systems/locale/messages.po | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/trunk/gosa-plugins/systems/admin/systems/services/class_goService.inc b/trunk/gosa-plugins/systems/admin/systems/services/class_goService.inc index 1134f1cd7..f48649c98 100644 --- a/trunk/gosa-plugins/systems/admin/systems/services/class_goService.inc +++ b/trunk/gosa-plugins/systems/admin/systems/services/class_goService.inc @@ -257,6 +257,29 @@ class goService extends plugin{ $this->$flag = $attrs[$flag][0]; } } + + function allow_remove() + { + /* Check if the service is still in use */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $cn = $ldap->getCn($this->dn); + $ldap->search("(&(|(objectClass=posixGroup)(objectClass=posixAccount))(gotoShare=$cn|*))", array("dn")); + + if($ldap->count()){ + /* Number of entries shown in warning */ + $i = 3; + $str = '

'; + while(($attrs = $ldap->fetch()) && $i >= 0){ + $i --; + if(isset($attrs['dn'])){ + $str .= '' . $attrs['dn']."
"; + } + } + $str .= '

'; + return(sprintf(_("Cannot remove share - it is still in use by these objects: %s"), $str)); + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/trunk/gosa-plugins/systems/locale/de/LC_MESSAGES/messages.po b/trunk/gosa-plugins/systems/locale/de/LC_MESSAGES/messages.po index eb1a60566..1c25a6107 100644 --- a/trunk/gosa-plugins/systems/locale/de/LC_MESSAGES/messages.po +++ b/trunk/gosa-plugins/systems/locale/de/LC_MESSAGES/messages.po @@ -280,6 +280,10 @@ msgstr "Leerer Dienst" msgid "Configuration error" msgstr "Konfigurationsfehler" +#: admin/systems/services/class_goService.inc:280 +msgid "Cannot remove share - it is still in use by these objects: %s" +msgstr "Freigabe kann nicht entfernt werden - sie wird noch von diesen Objekten benutzt: %s" + #: admin/systems/services/ServiceAddDialog.tpl:3 msgid "Adding a new service to the current server" msgstr "Hinzufügen eines neues Dienstes zum gewählten Server" diff --git a/trunk/gosa-plugins/systems/locale/messages.po b/trunk/gosa-plugins/systems/locale/messages.po index 92e6f14a2..958d05ddd 100644 --- a/trunk/gosa-plugins/systems/locale/messages.po +++ b/trunk/gosa-plugins/systems/locale/messages.po @@ -512,6 +512,10 @@ msgstr "" msgid "Restart" msgstr "" +#: admin/systems/services/class_goService.inc:280 +msgid "Cannot remove share - it is still in use by these objects: %s" +msgstr "" + #: admin/systems/class_serverService.inc:351 msgid "Information" msgstr "" -- 2.30.2