Code

Updated role acl and enabled save button, if we're allowed to do *something* with...
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 13 Nov 2006 08:41:57 +0000 (08:41 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 13 Nov 2006 08:41:57 +0000 (08:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5078 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_CopyPasteHandler.inc
plugins/admin/fai/class_faiHook.inc
plugins/admin/fai/class_faiManagement.inc
plugins/admin/fai/class_faiPackage.inc
plugins/admin/fai/class_faiProfile.inc
plugins/admin/fai/class_faiScript.inc
plugins/admin/fai/class_faiTemplate.inc

index 35b1937ef671f280d7ee95943da046ddce341c21..aba5e3208a3e1976722044ce7c416f4f8b51b2f1 100644 (file)
@@ -124,10 +124,18 @@ class CopyPasteHandler {
     /* Cut & paste
      */
     if($this->cutCurrent){
-      $this->current->save();
-      $this->dialogOpen =false;
-      $this->Clear();
 
+      $msgs = $this->check();  
+      if(count ($msgs) ){
+        foreach( $msgs as $msg){
+          print_red($msg);
+        }
+        $this->dialogOpen =false;
+      }else{
+        $this->current->save();
+        $this->dialogOpen =false;
+        $this->Clear();
+      }
       /* Copy & paste
        */
     }else{
index 6fa2680a2a8023e909bbbb862be696e9cef562b6..121d0ca5c9543fe64379a9264890fac1df92765f 100644 (file)
@@ -427,7 +427,11 @@ class faiHook extends plugin
     /* We do not need to save untouched objects */
     foreach($this->SubObjects as $name => $obj){
       if($obj['status'] == "FreshLoaded"){
-        unset($this->SubObjects[$name]);
+        if($this->copy_paste_mode){
+          $this->SubObjects[$name] = $this->get_object_attributes($obj,$this->sub_Load_Later);
+        }else{
+          unset($this->SubObjects[$name]);
+        }
       } 
     }
 
index b68f90f3ce7ffa669329c72abd2002441d09ec39..5d966c64e6588e9f2282d7db86ceb8966c0b37d4 100644 (file)
@@ -629,7 +629,7 @@ class faiManagement extends plugin
         $this->CopyPasteHandler->SetVar("base",             $this->DivListFai->selectedBase);
         $this->CopyPasteHandler->SetVar("copy_paste_mode",  TRUE);
     
-        $release = $_SESSION['CurrentMainBase'];
+        $release = "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase'];
         if($_SESSION['faifilter']['branch']!="main"){
                 $release = $_SESSION['faifilter']['branch'];
         }
index e2e112dc92e09ecef13c9d6b078a4bbd38c402d3..7697beb74c189ccf32691a0ba87e3630e7d5b78c 100644 (file)
@@ -64,6 +64,8 @@ class faiPackage extends plugin
   var $base             = "";
   var $release          = "";
   var $copy_paste_mode  = false;
+  var $CopyPasteVars  = array("FAIdebianRelease","FAIdebianSection","FAIinstallMethod","mirror","servers","releases","sections","list","mirrors","usedPackages");
+
 
   function faiPackage ($config, $dn= NULL)
   {
index 92969c28582859ddbe39f613c3e3af9b531bfd4c..1b11447e4dd890d3e6632f3c52c0c9e3993c73cd 100644 (file)
@@ -385,29 +385,45 @@ class faiProfile extends plugin
     /* Call common method to give check the hook */
     $message= plugin::check();
 
-    if(count($this->FAIclasses) == 0){
-      $message[]=_("Please assign at least one class to this  profile.");
-    }
+    if($this->copy_paste_mode){
 
-    if(empty($this->cn)){
-      $message[]=_("Please enter a valid name.");
-    }
+      /* If this is a new script, check if a script with this name already exists */
+      if(!empty($this->release) && $this->copy_paste_mode){
 
-    $ldap = $this->config->get_ldap_link();
-    $release = "ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase'];
-    if($_SESSION['faifilter']['branch']!="main"){
-      $release = "ou=profiles,".$_SESSION['faifilter']['branch'];
-    }
-    $ldap->cd($release);
-    if ($this->old_cn == ""){
-      $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn."))",array("*"));
-    } else {
-      $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",array("*"));
-    }
-    if($ldap->count()){
-      $message[]=_("There is already a profile with this class name defined.");
+        /* Check if current name is already used for fai scripts in selected release */
+        $dn = 'cn='.$this->cn.",ou=profiles,".$this->release;
+        $ldap = $this->config->get_ldap_link();
+        $ldap->cat($dn);
+        if($ldap->count()){
+
+          $r =convert_department_dn($this->release);;
+          $message[] = sprintf(_("Can't insert a script named '%s' in '%s' there is already a script with the given name."),$this->cn,$r);
+        }
+      }
+    }else{
+      if(count($this->FAIclasses) == 0){
+        $message[]=_("Please assign at least one class to this  profile.");
+      }
+
+      if(empty($this->cn)){
+        $message[]=_("Please enter a valid name.");
+      }
+
+      $ldap = $this->config->get_ldap_link();
+      $release = "ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase'];
+      if($_SESSION['faifilter']['branch']!="main"){
+        $release = "ou=profiles,".$_SESSION['faifilter']['branch'];
+      }
+      $ldap->cd($release);
+      if ($this->old_cn == ""){
+        $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn."))",array("*"));
+      } else {
+        $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",array("*"));
+      }
+      if($ldap->count()){
+        $message[]=_("There is already a profile with this class name defined.");
+      }
     }
-    
     return ($message);
   }
 
index 935b771b2b6d1e17d35c5c76b8d8c9af09be8e4a..50a73992b4c9a19d9ff89b4cf556ac7a4f90f43e 100644 (file)
@@ -41,6 +41,8 @@ class faiScript extends plugin
   var $base             ="";
   var $release          ="";
   var $copy_paste_mode  = false;
+  var $CopyPasteVars    = array("SubObjects","FAIstate");
+
 
   function faiScript ($config, $dn= NULL)
   {
@@ -397,7 +399,11 @@ class faiScript extends plugin
     /* We do not need to save untouched objects */
     foreach($this->SubObjects as $name => $obj){
       if($obj['status'] == "FreshLoaded"){
-        unset($this->SubObjects[$name]);
+        if($this->copy_paste_mode){
+          $this->SubObjects[$name] = $this->get_object_attributes($obj,$this->sub_Load_Later);
+        }else{
+          unset($this->SubObjects[$name]);
+        }
       }
     }
 
index e34f5d4bb275f8dc4c4eb5dda020361fc022735a..1b2f78752291fa26a737574c7b5678b23b75658d 100644 (file)
@@ -394,7 +394,11 @@ class faiTemplate extends plugin
     /* We do not need to save untouched objects */
     foreach($this->SubObjects as $name => $obj){
       if($obj['status'] == "FreshLoaded"){
-        unset($this->SubObjects[$name]);
+        if($this->copy_paste_mode){
+          $this->SubObjects[$name] = $this->get_object_attributes($obj,$this->sub_Load_Later);
+        }else{
+          unset($this->SubObjects[$name]);
+        }
       }
     }
 
@@ -420,8 +424,10 @@ class faiTemplate extends plugin
       foreach($attributes as $attrs){
         if(empty($obj[$attrs])){
           $obj[$attrs] = array();
+          $tmp[$attrs] = $obj[$attrs];
+        }else{
+          $tmp[$attrs] = stripslashes ($obj[$attrs]);
         }
-        $tmp[$attrs] = stripslashes ($obj[$attrs]);
       }    
         
       $tmp['objectClass'] = $this->subClasses;