Code

inserted Check "You can't delete a phone, when it is assigned to a person ...
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 8 Aug 2005 11:52:34 +0000 (11:52 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 8 Aug 2005 11:52:34 +0000 (11:52 +0000)
first remove assignment, then delete phone ..."

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1076 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_phoneGeneric.inc
plugins/admin/systems/class_systemManagement.inc

index dfe1b4e148eeac86d02f257265edd0e753537680..11a0509d417c4854cbb87c6bb70706688b6db35e 100644 (file)
@@ -96,8 +96,6 @@ class phoneGeneric extends plugin
 
   function execute()
   {
-  
     /* Do we represent a valid phone? */
     if (!$this->is_account && $this->parent == NULL){
       $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
@@ -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");
index 6efa50af39b2dfa034c1f719944dbe153cfc0431..03aca02f7de422421937333c3b2a97b7fd2b7d9d 100644 (file)
@@ -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;