Code

Allow copy & paste for profiles
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 11 Apr 2008 09:12:41 +0000 (09:12 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 11 Apr 2008 09:12:41 +0000 (09:12 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10350 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiProfile.inc

index c6c4c2f53a3c831140a3530a8a6c5cfacc1f3572..212ea1dde18fa07d0c745a69efe648c10a26e30c 100644 (file)
@@ -398,23 +398,18 @@ class faiProfile extends plugin
       $message[]= msgPool::invalid(_("Name"));
     }
 
-    $ldap = $this->config->get_ldap_link();
-    $faifilter = session::get('faifilter');
-    $base = $faifilter['branch'];
-    if($base == "main"){
-      $base  = session::get('CurrentMainBase');
-    }
-    $base = get_ou('faiprofileou').$base;
-  
-    $ldap->cd($base);
-    if ($this->old_cn == ""){
-      $ldap->ls("(&(objectClass=FAIprofile)(cn=".$this->cn."))",$base,array("*"));
-    } else {
-      $ldap->ls("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",$base,array("*"));
-    }
-
-    if($ldap->count() || isset($this->FAIAllclasses[$this->cn])){
-      $message[]= msgPool::duplicated(_("Name"));
+    /* Ensure that we do not overwrite an allready existing entry 
+     */
+    if($this->dn == "new" || $this->cn != $this->old_cn){
+      $new_dn= 'cn='.$this->cn.",".get_ou('faiprofileou').get_ou('faiou').session::get('CurrentMainBase');
+      $faifilter = session::get('faifilter');
+      if($faifilter['branch']!="main"){
+        $new_dn ='cn='.$this->cn.",".get_ou('faiprofileou').$faifilter['branch'];
+      }
+      $res = faiManagement::check_class_name("FAIprofile",$this->cn,$new_dn);
+      if(isset($res[$this->cn])){
+        $message[] = msgPool::duplicated(_("Name"));
+      }
     }
 
     return ($message);
@@ -484,6 +479,34 @@ class faiProfile extends plugin
             "FAIclass"          => _("FAI classes"))
           ));
   }
+
+
+  /*! \brief  Used for copy & paste.
+              Returns a HTML input mask, which allows to change the cn of this entry.
+      @param  Array   Array containing current status && a HTML template.
+   */
+  function getCopyDialog()
+  {
+    $vars = array("cn");
+    $smarty = get_smarty();
+    $smarty->assign("cn", htmlentities($this->cn));
+    $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+
+  /*! \brief  Used for copy & paste.
+              Some entries must be renamed to avaoid duplicate entries.
+   */
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = get_post('cn');
+    }
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: