From: hickert Date: Mon, 8 Aug 2005 11:52:34 +0000 (+0000) Subject: inserted Check "You can't delete a phone, when it is assigned to a person ... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2ea368c97c2d89a6e1dc84ca218a3ee3843e6c23;p=gosa.git inserted Check "You can't delete a phone, when it is assigned to a person ... first remove assignment, then delete phone ..." git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1076 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_phoneGeneric.inc b/plugins/admin/systems/class_phoneGeneric.inc index dfe1b4e14..11a0509d4 100644 --- a/plugins/admin/systems/class_phoneGeneric.inc +++ b/plugins/admin/systems/class_phoneGeneric.inc @@ -96,8 +96,6 @@ class phoneGeneric extends plugin function execute() { - - /* Do we represent a valid phone? */ if (!$this->is_account && $this->parent == NULL){ $display= "\"\" ". @@ -208,6 +206,15 @@ class phoneGeneric extends plugin function remove_from_parent() { $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + $ldap->search ("(&(objectClass=goFonAccount)(goFonHardware=".$this->cn."))", array("uid","cn")); + while ($attr = $ldap->fetch()){ + print_red(sprintf(_("Can't delete the phone. There are still users using this phone, one of them is user '%s'."), + ($attr['uid'][0]." - ".$attr['cn'][0]))); + return; + } + $ldap->rmdir($this->dn); show_ldap_error($ldap->get_error()); $this->handle_post_events("remove"); diff --git a/plugins/admin/systems/class_systemManagement.inc b/plugins/admin/systems/class_systemManagement.inc index 6efa50af3..03aca02f7 100644 --- a/plugins/admin/systems/class_systemManagement.inc +++ b/plugins/admin/systems/class_systemManagement.inc @@ -424,6 +424,10 @@ class systems extends plugin case "workstation": $tabtype= "worktabs"; break; + + case "phone": + $tabtype= "phonetabs"; + break; case "server": $tabtype= "servtabs"; @@ -438,10 +442,17 @@ class systems extends plugin } /* Delete request is permitted, perform LDAP action */ - $this->systab= new $tabtype($this->config, - $this->config->data['TABS']['TERMTABS'], $this->dn); - $this->systab->set_acl(array($this->acl)); - $this->systab->by_object['termgeneric']->remove_from_parent (); + if($tabtype=="phonetabs"){ + $this->systab= new $tabtype($this->config, + $this->config->data['TABS']['PHONETABS'], $this->dn); + $this->systab->set_acl(array($this->acl)); + $this->systab->by_object['phonegeneric']->remove_from_parent (); + }else{ + $this->systab= new $tabtype($this->config, + $this->config->data['TABS']['TERMTABS'], $this->dn); + $this->systab->set_acl(array($this->acl)); + $this->systab->by_object['termgeneric']->remove_from_parent (); + } unset ($this->systab); gosa_log ("System object'".$this->dn."' has been removed"); $this->systab= NULL;