Code

Moved copy&paste into a seperate function
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Apr 2006 04:42:22 +0000 (04:42 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Apr 2006 04:42:22 +0000 (04:42 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3111 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/applications/class_applicationManagement.inc
plugins/admin/groups/class_groupManagement.inc

index 2eaa67e2164a5f6e906e5efd81d892148ab12257..f82a5013e5a185116a6890eec0370511559934c1 100644 (file)
@@ -31,12 +31,11 @@ class applicationManagement extends plugin
   var $ui= NULL;
   var $acl= "";
 
-  var $CopyPasteHandler ;
+  var $CopyPasteHandler = NULL;
 
   var $Release  = "";
   var $Releases = array();
 
-  var $enableCopyPaste         = false;
   var $enableReleaseManagement = false;
 
 
@@ -46,14 +45,12 @@ class applicationManagement extends plugin
     $this->config= $config;
     $this->ui= $ui;
 
-    if( (isset($this->config->data['MAIN']['ENABLECOPYPASTE'])) 
+    if((isset($this->config->data['MAIN']['ENABLECOPYPASTE'])) 
         && 
         (preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE'] ))){
-      $this->enableCopyPaste = true;
+      $this->CopyPasteHandler = new CopyPasteHandler($this->config);
     }
 
-    $this->CopyPasteHandler = new CopyPasteHandler($this->config);
-
     /* Check if we should enable the release selection */
     $tmp = search_config($this->config->data,"faiManagement","CLASS");
     if(!empty($tmp)){
@@ -238,39 +235,10 @@ class applicationManagement extends plugin
 
     /* Only perform copy / paste if it is enabled 
      */
-    if($this->enableCopyPaste){
-
-      /* Paste copied/cutted object in here
-       */
-      if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){
-        $this->CopyPasteHandler->save_object();
-        $this->CopyPasteHandler->SetVar("base", $_SESSION['CurrentMainBase']);
-
-        if($str = $this->CopyPasteHandler->execute()) {
-          return($str);
-        }
-      }
-
-
-      /* Copy current object to CopyHandler
-       */
-      if($s_action == "copy"){
-        $this->CopyPasteHandler->Clear();
-        $dn = $this->applications[$s_entry]['dn'];
-        $obj    = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn);
-        $objNew = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], "new");
-        $this->CopyPasteHandler->Copy($obj,$objNew);
-      }
-
-
-      /* Copy current object to CopyHandler
-       */
-      if($s_action == "cut"){
-        $this->CopyPasteHandler->Clear();
-        $dn = $this->applications[$s_entry]['dn'];
-        $obj = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn);
-        $this->CopyPasteHandler->Cut($obj);
-      }
+    if($this->CopyPasteHandler){
+      if($str = $this->copyPasteHandling($s_action,$s_entry)){
+       return($str);
+      };
     }
 
     /* New application? */
@@ -452,7 +420,7 @@ class applicationManagement extends plugin
       }
     }
 
-    if($this->enableCopyPaste){
+    if($this->CopyPasteHandler){
       $Copy_Paste = " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
 
       if($this->CopyPasteHandler->isCurrentObjectPastAble()){
@@ -488,7 +456,7 @@ class applicationManagement extends plugin
 
 
 
-    if($this->enableCopyPaste){
+    if($this->CopyPasteHandler){
       $actions = "<input class='center' type='image' 
         src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
       $actions.= "<input class='center' type='image' 
@@ -665,6 +633,40 @@ class applicationManagement extends plugin
   }
 
 
+  function copyPasteHandling($s_action,$s_entry)
+  {
+    /* Paste copied/cutted object in here
+     */
+    echo "jo";
+    if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){
+      $this->CopyPasteHandler->save_object();
+      $this->CopyPasteHandler->SetVar("base", $_SESSION['CurrentMainBase']);
+
+      if($str = $this->CopyPasteHandler->execute()) {
+        return($str);
+      }
+    }
+
+    /* Copy current object to CopyHandler
+     */
+    if($s_action == "copy"){
+      $this->CopyPasteHandler->Clear();
+      $dn = $this->applications[$s_entry]['dn'];
+      $obj    = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn);
+      $objNew = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], "new");
+      $this->CopyPasteHandler->Copy($obj,$objNew);
+    }
+
+    /* Copy current object to CopyHandler
+     */
+    if($s_action == "cut"){
+      $this->CopyPasteHandler->Clear();
+      $dn = $this->applications[$s_entry]['dn'];
+      $obj = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn);
+      $this->CopyPasteHandler->Cut($obj);
+    }
+  }
+
   /* Save data to object */
   function save_object()
   {
index 70bb5499a921cc48af95917a893655b7c6ff29f9..75b1dbf6746331e617afc64dbe85b48ba6b9f8f2 100644 (file)
@@ -32,8 +32,7 @@ class groupManagement extends plugin
   var $ui= NULL;
   var $acl= "";
 
-  var $CopyPasteHandler ;
-  var $enableCopyPaste = false;
+  var $CopyPasteHandler  = NULL;
 
   function groupManagement ($config, $ui)
   {
@@ -42,9 +41,8 @@ class groupManagement extends plugin
     $this->ui= $ui;
 
     if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){
-      $this->enableCopyPaste = true;
+      $this->CopyPasteHandler = new CopyPasteHandler($this->config);
     }
-    $this->CopyPasteHandler = new CopyPasteHandler($this->config);
 
     /* Get global filter config */
     if (!is_global("groupfilter")){
@@ -202,54 +200,14 @@ class groupManagement extends plugin
       return($message);
     }
 
-    /* Only perform copy / paste if it is enabled
+    /* Only perform copy&paste requests if it is enabled
      */
-    if($this->enableCopyPaste){
-
-      /* Paste copied/cutted object in here
-       */
-      if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){
-        $this->CopyPasteHandler->save_object();
-        $this->CopyPasteHandler->SetVar("base",$_SESSION['CurrentMainBase']);
-        if($str = $this->CopyPasteHandler->execute()){
-          return( $str);
-        };
-        /* Ensure that the new object is shown in the list now */
-        $this->relaod();
-      }
-
-
-      /* Copy current object to CopyHandler
-       */
-      if($s_action == "copy"){
-        $this->CopyPasteHandler->Clear();
-        
-        $dn     = $this->grouplist[trim($s_entry)]['dn'];
-        $acl    = get_permissions ($dn, $this->ui->subtreeACL);
-
-        $obj    = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
-        $objNew = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], "new");
-        $obj->set_acl($acl);
-        $objNew->set_acl($acl);
-        $this->CopyPasteHandler->Copy($obj,$objNew);
-      }
-
-
-      /* Copy current object to CopyHandler
-       */
-      if($s_action == "cut"){
-        $this->CopyPasteHandler->Clear();
-        $dn = $this->grouplist[trim($s_entry)]['dn'];
-        $acl= get_permissions ($dn, $this->ui->subtreeACL);
-
-        $obj= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
-        $obj->set_acl($acl);
-
-        $this->CopyPasteHandler->Cut($obj);
+    if($this->CopyPasteHandler){
+      if($str = $this->copyPasteHandling($s_action,$s_entry)){
+        echo $str;
       }
     }
 
-
     /* New group? */
     if ($s_action=="new"){
 
@@ -431,7 +389,7 @@ class groupManagement extends plugin
 
     /* Create paste icon 
      */
-    if($this->enableCopyPaste){
+    if($this->CopyPasteHandler){
       $Copy_Paste = " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
       if($this->CopyPasteHandler->isCurrentObjectPastAble()){
         if($this->CopyPasteHandler->isCurrentCutted()){
@@ -463,7 +421,7 @@ class groupManagement extends plugin
       "</div>";
 
     
-    if($this->enableCopyPaste){
+    if($this->CopyPasteHandler){
       $actions = "<input class='center' type='image'
         src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
       $actions.= "<input class='center' type='image'
@@ -745,6 +703,56 @@ class groupManagement extends plugin
   }
 
 
+
+
+  /* Perform copy & paste requests
+     If copy&paste is in progress this returns a dialog to fix required attributes 
+   */ 
+  function copyPasteHandling($s_action,$s_entry)
+  {
+    /* Paste copied/cutted object in here
+     */
+    if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){
+      $this->CopyPasteHandler->save_object();
+      $this->CopyPasteHandler->SetVar("base",$_SESSION['CurrentMainBase']);
+      if($str = $this->CopyPasteHandler->execute()){
+        return( $str);
+      };
+      /* Ensure that the new object is shown in the list now */
+      $this->relaod();
+    }
+
+
+    /* Copy current object to CopyHandler
+     */
+    if($s_action == "copy"){
+      $this->CopyPasteHandler->Clear();
+
+      $dn     = $this->grouplist[trim($s_entry)]['dn'];
+      $acl    = get_permissions ($dn, $this->ui->subtreeACL);
+
+      $obj    = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
+      $objNew = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], "new");
+      $obj->set_acl($acl);
+      $objNew->set_acl($acl);
+      $this->CopyPasteHandler->Copy($obj,$objNew);
+    }
+
+
+    /* Copy current object to CopyHandler
+     */
+    if($s_action == "cut"){
+      $this->CopyPasteHandler->Clear();
+      $dn = $this->grouplist[trim($s_entry)]['dn'];
+      $acl= get_permissions ($dn, $this->ui->subtreeACL);
+
+      $obj= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
+      $obj->set_acl($acl);
+
+      $this->CopyPasteHandler->Cut($obj);
+    }
+  }
+
   /* Save data to object */
   function save_object()
   {