Code

Exlude dhcp entries from existence check in check()
[gosa.git] / plugins / admin / systems / class_phoneGeneric.inc
index 7b55449d99a83782c77be1c85c6586d0da3c75bc..fc2ce9d6095333faa52b59a352e0bd8556558ace 100644 (file)
@@ -32,6 +32,7 @@ class phoneGeneric extends plugin
   var $goFonMSN         = "";
   var $selected_categorie    = 0;
   var $netConfigDNS;
+  var $view_logged      = FALSE;
 
   /* attribute list for save action */
   var $attributes= array("cn", "description",
@@ -92,10 +93,6 @@ class phoneGeneric extends plugin
 
     /* Save dn for later references */
     $this->orig_dn= $this->dn;
-
-    if($this->is_account){
-      @log::log("view","phone/".get_class($this),$this->dn);
-    }
   }
 
   function set_acl_base($base)
@@ -113,8 +110,13 @@ class phoneGeneric extends plugin
 
   function execute()
   {
-       /* Call parent execute */
-       plugin::execute();
+    /* Call parent execute */
+    plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","phone/".get_class($this),$this->dn);
+    }
 
     /* Do we represent a valid phone? */
     if (!$this->is_account && $this->parent == NULL){
@@ -271,7 +273,7 @@ class phoneGeneric extends plugin
       $this->netConfigDNS->remove_from_parent();
       $ldap->rmdir($this->dn);
   
-      @log::log("remove","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      new log("remove","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
 
       show_ldap_error($ldap->get_error(), sprintf(_("Removing of system phone/generic with dn '%s' failed."),$this->dn));
       $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
@@ -341,6 +343,11 @@ class phoneGeneric extends plugin
       $ldap->search ("(cn=".$this->cn.")", array("cn"));
       if ($ldap->count() != 0){
         while ($attrs= $ldap->fetch()){
+
+          if(preg_match("/cn=dhcp,/",$attrs['dn'])){
+            continue;
+          }
+  
           if ($attrs['dn'] != $this->orig_dn){
             $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
             break;
@@ -360,7 +367,7 @@ class phoneGeneric extends plugin
    
    
     /* only to define which attrs to save*/ 
-    $mode = $this->attrs['selected_categorie'];
+    $mode = $this->selected_categorie;
 
     /* Remove all unwanted attrs */
     foreach($this->attributes as $att){
@@ -399,7 +406,7 @@ class phoneGeneric extends plugin
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);
-      @log::log("create","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      new log("create","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
       $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
     } else {
       if ($this->orig_dn != $this->dn){
@@ -409,7 +416,7 @@ class phoneGeneric extends plugin
       $ldap->cd($this->dn);
       $this->cleanup();
       $ldap->modify ($this->attrs); 
-      @log::log("modify","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      new log("modify","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
 
       // $user_phone_reload   
       $ldap->cd ($this->config->current['BASE']); 
@@ -428,6 +435,44 @@ class phoneGeneric extends plugin
   }
 
 
+  /* Display generic part for server copy & paste */
+  function getCopyDialog()
+  {
+    $vars = array("cn");
+    $smarty = get_smarty();
+    $smarty->assign("cn" ,$this->cn);
+    $smarty->assign("object","phone");
+    $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = $_POST['cn'];
+    }
+  }
+
+
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+    if(isset($source['macAddress'][0])){
+      $this->netConfigDNS->macAddress = $source['macAddress'][0];
+    }
+    if(isset($source['ipHostNumber'][0])){
+      $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
+    }
+
+    $source_o = new phonegeneric($this->config, $source['dn']);
+    $this->selected_categorie = $source_o->selected_categorie;
+  }
+
+
   /* Return plugin informations for acl handling
       #FIXME FAIscript seams to ununsed within this class... */
   function plInfo()