Code

Moved snapshot management into plugin
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Jun 2006 10:54:28 +0000 (10:54 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Jun 2006 10:54:28 +0000 (10:54 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3799 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_MultiSelectWindow.inc
include/class_plugin.inc
plugins/admin/groups/class_divListGroup.inc
plugins/admin/groups/class_groupManagement.inc
plugins/admin/systems/class_divListSystem.inc
plugins/admin/systems/class_systemManagement.inc
plugins/admin/systems/snapshotdialog.tpl
plugins/admin/users/class_divListUsers.inc
plugins/admin/users/class_userManagement.inc

index 00d49d6d57c74d175f18172fc0a8df16cf8f8a19..8481095f07e457aaf426bc5402a57d0a5ff075e6 100644 (file)
@@ -483,6 +483,27 @@ class MultiSelectWindow{
 
        }
 
+
+  function GetSnapShotActions($dn)
+  {
+    $str = "";
+
+    if($this->parent->snapshotEnabled()){
+
+      $str .="<input class='center' type='image' src='images/snapshot.png'
+        alt='"._("Create snapshot")."' name='CreateSnapShot_".base64_encode($dn)."' title='"._("Create a new snapshot from this object")."'>&nbsp;";
+
+      if(count($this->parent->Available_SnapsShots($dn))){
+        $str .="<input class='center' type='image' src='images/restore.png'
+          alt='"._("Restore snapshot")."' name='RestoreSnapShot_".base64_encode($dn)."' title='"._("Restore snapshot")."'>&nbsp;";
+      }else{
+        $str.= "<img src='images/empty.png' style='width:16px;' class='center'>&nbsp;";
+      }
+    }
+    return($str);
+  }
+
+
        /* this function adds the sub-departments of the current tree to the list */
        function AddDepartments($base = false,$numtabs = 3)
        {
index 2a34d2c55d6e8a378b26c547a600233d61cd378d..a80b8511b71063ac86fbf91e4ab637f8354b6bc2 100644 (file)
@@ -100,6 +100,7 @@ class plugin
   var $givenName= "";
   var $acl= "*none*";
   var $dialog= FALSE;
+  var $snapDialog = NULL;
 
   /* attribute list for save action */
   var $attributes= array();
@@ -1228,6 +1229,75 @@ class plugin
     show_ldap_error($ldap_to->get_error().$err, _("Restore snapshot failed."));
   }
 
+
+  function showSnapshotDialog($base,$baseSuffix)
+  {
+    $once = true;
+    foreach($_POST as $name => $value){
+
+      /* Create a new snapshot, display a dialog */
+      if(preg_match("/^CreateSnapShot_/",$name) && $once){
+        $once = false;
+        $entry = preg_replace("/^CreateSnapShot_/","",$name);
+        $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
+        $this->snapDialog = new SnapShotDialog($this->config,$entry,$this);
+      }
+
+      /* Restore a snapshot, display a dialog with all snapshots of the current object */
+      if(preg_match("/^RestoreSnapShot_/",$name) && $once){
+        $once = false;
+        $entry = preg_replace("/^RestoreSnapShot_/","",$name);
+        $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
+        $this->snapDialog = new SnapShotDialog($this->config,$entry,$this);
+        $this->snapDialog->Restore = true;
+      }
+
+      /* Restore one of the already deleted objects */
+      if(preg_match("/^RestoreDeletedSnapShot_/",$name) && $once){
+        $once = false;
+        $entry = $baseSuffix.$base;
+        $this->snapDialog = new SnapShotDialog($this->config,$entry,$this);
+        $this->snapDialog->Restore      = true;
+        $this->snapDialog->DeletedOnes  = true;
+      }
+    }
+
+    /* Create a new snapshot requested, check
+       the given attributes and create the snapshot*/
+    if(isset($_POST['CreateSnapshot'])){
+      $this->snapDialog->save_object();
+      $msgs = $this->snapDialog->check();
+      if(count($msgs)){
+        foreach($msgs as $msg){
+          print_red($msg);
+        }
+      }else{
+        $this->dn =  $this->snapDialog->dn;
+        $this->create_snapshot("snapshot",$this->snapDialog->CurrentDescription);
+        $this->snapDialog = NULL;
+      }
+    }
+
+    /* Restore is requested, restore the object with the posted dn .*/
+    if((isset($_POST['RestoreSnapshot'])) && (isset($_POST['SnapShot']))){
+      $entry =trim($_POST['SnapShot']);
+      if(!empty($entry)){
+        $entry = base64_decode($entry);
+        $this->restore_snapshot($entry);
+        $this->snapDialog = NULL;
+      }
+    }
+   
+    if(isset($_POST['CancelSnapshot'])){
+      $this->snapDialog = NULL;
+    }
+    if($this->snapDialog){
+      $this->snapDialog->save_object();
+      return($this->snapDialog->execute());
+    }
+
+  }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index 30b1df8a439aac22d4beb18a85b0c19bf7189c4c..13e97e2ac40a5a5b878db3b480764f4ba1ca0ac7 100644 (file)
@@ -67,26 +67,6 @@ class divListGroup extends MultiSelectWindow
   }
 
 
- function GetSnapShotActions($dn)
-  {
-    $str = "";
-
-    if($this->parent->snapshotEnabled()){
-
-      $str .="<input class='center' type='image' src='images/snapshot.png'
-        alt='"._("Create snapshot")."' name='CreateSnapShot_".base64_encode($dn)."' title='"._("Create a new snapshot from this object")."'>&nbsp;";
-
-      if(count($this->parent->Available_SnapsShots($dn))){
-        $str .="<input class='center' type='image' src='images/restore.png'
-          alt='"._("Restore snapshot")."' name='RestoreSnapShot_".base64_encode($dn)."' title='"._("Restore snapshot")."'>&nbsp;";
-      }else{
-        $str.= "<img src='images/empty.png' style='width:16px;' class='center'>&nbsp;";
-      }
-    }
-    return($str);
-  }
-
-
   function GenHeader()
   {
     /* Prepare departments,
index 305fd6a9c82657f959ec9aabbd9b922856d9f7bc..69ca59c013d504b67fb44712969659327a75239d 100644 (file)
@@ -340,6 +340,12 @@ class groupManagement extends plugin
       return ($display);
     }
 
+    
+    /* Check if there is a snapshot dialog open */
+    if($str = $this->showSnapshotDialog($this->DivListGroup->selectedBase,get_groups_ou())){
+      return($str);
+    }
+
     /* Display dialog with group list */
     $this->DivListGroup->parent = $this;
     $this->DivListGroup->execute();
@@ -522,61 +528,6 @@ class groupManagement extends plugin
   function save_object()
   {
     $this->DivListGroup->save_object();
-        $once = true;
-    foreach($_POST as $name => $value){
-
-      /* Create a new snapshot, display a dialog */
-      if(preg_match("/^CreateSnapShot_/",$name) && $once){
-        $once = false;
-        $entry = preg_replace("/^CreateSnapShot_/","",$name);
-        $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
-        $this->grouptab = new SnapShotDialog($this->config,$entry,$this);
-      }
-
-      /* Restore a snapshot, display a dialog with all snapshots of the current object */
-      if(preg_match("/^RestoreSnapShot_/",$name) && $once){
-        $once = false;
-        $entry = preg_replace("/^RestoreSnapShot_/","",$name);
-        $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
-        $this->grouptab = new SnapShotDialog($this->config,$entry,$this);
-        $this->grouptab->Restore = true;
-      }
-
-      /* Restore one of the already deleted objects */
-      if(preg_match("/^RestoreDeletedSnapShot_/",$name) && $once){
-        $once = false;
-        $entry = get_groups_ou().$this->DivListGroup->selectedBase;
-        $this->grouptab = new SnapShotDialog($this->config,$entry,$this);
-        $this->grouptab->Restore      = true;
-        $this->grouptab->DeletedOnes  = true;
-      }
-    }
-
-    /* Create a new snapshot requested, check
-       the given attributes and create the snapshot*/
-    if(isset($_POST['CreateSnapshot'])){
-      $this->grouptab->save_object();
-      $msgs = $this->grouptab->check();
-      if(count($msgs)){
-        foreach($msgs as $msg){
-          print_red($msg);
-        }
-      }else{
-        $this->dn =  $this->grouptab->dn;
-        $this->create_snapshot("snapshot",$this->grouptab->CurrentDescription);
-        $this->grouptab = NULL;
-      }
-    }
-
-    /* Restore is requested, restore the object with the posted dn .*/
-    if((isset($_POST['RestoreSnapshot'])) && (isset($_POST['SnapShot']))){
-      $entry =trim($_POST['SnapShot']);
-      if(!empty($entry)){
-        $entry = base64_decode($entry);
-        $this->restore_snapshot($entry);
-        $this->grouptab = NULL;
-      }
-    }
   }
 
 
index 008c519f8d81f507da7d2120e985b34ec56cf570..3cdd8cb9eccf98fc0a36b13e2555fc712c1ea101 100644 (file)
@@ -126,25 +126,6 @@ class divListSystem extends MultiSelectWindow
   }
 
 
-  function GetSnapShotActions($dn)
-  {
-    $str = "";
-
-    if($this->parent->snapshotEnabled()){
-
-      $str .="<input class='center' type='image' src='images/snapshot.png' 
-        alt='"._("Create snapshot")."' name='CreateSnapShot_".base64_encode($dn)."' title='"._("Create a new snapshot from this object")."'>&nbsp;";
-
-      if(count($this->parent->Available_SnapsShots($dn))){
-        $str .="<input class='center' type='image' src='images/restore.png' 
-          alt='"._("Restore snapshot")."' name='RestoreSnapShot_".base64_encode($dn)."' title='"._("Restore snapshot")."'>&nbsp;";
-      }else{
-        $str.= "<img src='images/empty.png' style='width:16px;' class='center'>&nbsp;";
-      }
-    }
-    return($str);
-  }
-
   function setEntries($terminals)
   {
     $img1  = "<img class='center' src='images/printer.png'            alt='C' title='"._("Cups Server")  ."'>";
index 8b945d5519dc045325ee8a57bb7b7b1fc996eaa8..a94d4b4d5f3093c61ba7b57194d53c76687a1044 100644 (file)
@@ -487,6 +487,11 @@ class systems extends plugin
       return ($display);
     }
 
+    /* Check if there is a snapshot dialog open */
+    if($str = $this->showSnapshotDialog($this->DivListSystem->selectedBase,"ou=systems,")){
+      return($str);
+    }
+
     /* Display dialog with system list */
     $this->DivListSystem->parent = $this;
     $this->DivListSystem->execute();
@@ -513,62 +518,6 @@ class systems extends plugin
   function save_object()
   {
     $this->DivListSystem->save_object();
-    /* check for posts */
-    $once = true;
-    foreach($_POST as $name => $value){
-
-      /* Create a new snapshot, display a dialog */
-      if(preg_match("/^CreateSnapShot_/",$name) && $once){
-        $once = false;
-        $entry = preg_replace("/^CreateSnapShot_/","",$name);
-        $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
-        $this->systab = new SnapShotDialog($this->config,$entry,$this); 
-      }
-
-      /* Restore a snapshot, display a dialog with all snapshots of the current object */
-      if(preg_match("/^RestoreSnapShot_/",$name) && $once){
-        $once = false;
-        $entry = preg_replace("/^RestoreSnapShot_/","",$name);
-        $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
-        $this->systab = new SnapShotDialog($this->config,$entry,$this); 
-        $this->systab->Restore = true;
-      }
-
-      /* Restore one of the already deleted objects */
-      if(preg_match("/^RestoreDeletedSnapShot_/",$name) && $once){
-        $once = false;
-        $entry = "ou=systems,".$this->DivListSystem->selectedBase;  
-        $this->systab = new SnapShotDialog($this->config,$entry,$this); 
-        $this->systab->Restore      = true;
-        $this->systab->DeletedOnes  = true;
-      }
-    }
-
-    /* Create a new snapshot requested, check 
-       the given attributes and create the snapshot*/
-    if(isset($_POST['CreateSnapshot'])){
-      $this->systab->save_object();
-      $msgs = $this->systab->check();
-      if(count($msgs)){
-        foreach($msgs as $msg){
-          print_red($msg);
-        }
-      }else{
-        $this->dn =  $this->systab->dn;
-        $this->create_snapshot("snapshot",$this->systab->CurrentDescription);
-        $this->systab = NULL;
-      }
-    }
-
-    /* Restore is requested, restore the object with the posted dn .*/ 
-    if((isset($_POST['RestoreSnapshot'])) && (isset($_POST['SnapShot']))){
-      $entry =trim($_POST['SnapShot']);
-      if(!empty($entry)){
-        $entry = base64_decode($entry);
-        $this->restore_snapshot($entry);
-        $this->systab = NULL;
-      }
-    }
   }
 
 
index e3d1035599c2a181786041ac8c956a3f9cc5863a..a285725a2824c81f3dc8b036c42bc97d11c26c48 100755 (executable)
@@ -47,7 +47,7 @@
 <div style="width:100%; text-align:right;">
     <input type='submit' name='RestoreSnapshot' value='{t}Save{/t}' {if $CountSnapShots==0} disabled {/if}>
     &nbsp;
-    <input type='submit' name='edit_cancel' value='{t}Cancel{/t}'>
+    <input type='submit' name='CancelSnapshot' value='{t}Cancel{/t}'>
 </div></p>
 {else}
 
@@ -94,6 +94,6 @@
 <div style="width:100%; text-align:right;">
     <input type='submit' name='CreateSnapshot' value='{t}Save{/t}'>
     &nbsp;
-    <input type='submit' name='edit_cancel' value='{t}Cancel{/t}'>
+    <input type='submit' name='CancelSnapshot' value='{t}Cancel{/t}'>
 </div></p>
 {/if}
index 55efed9eed4225a3b6ec9d7412eaafc0c89f0f5c..d9e7d434e7bf44bb4d008ac73b1597e87f2c6a7d 100644 (file)
@@ -66,25 +66,6 @@ class divListUsers extends MultiSelectWindow
     $this->AddRegex   ("Regex",     _("Display users matching"),"*" , true);
   }
 
-  function GetSnapShotActions($dn)
-  {
-    $str = "";
-
-    if($this->parent->snapshotEnabled()){
-
-      $str .="<input class='center' type='image' src='images/snapshot.png'
-        alt='"._("Create snapshot")."' name='CreateSnapShot_".base64_encode($dn)."' title='"._("Create a new snapshot from this object")."'>&nbsp;";
-
-      if(count($this->parent->Available_SnapsShots($dn))){
-        $str .="<input class='center' type='image' src='images/restore.png'
-          alt='"._("Restore snapshot")."' name='RestoreSnapShot_".base64_encode($dn)."' title='"._("Restore snapshot")."'>&nbsp;";
-      }else{
-        $str.= "<img src='images/empty.png' style='width:16px;' class='center'>&nbsp;";
-      }
-    }
-    return($str);
-  }
-
 
   function GenHeader()
   {
index ebe79b496b4ca10e9378dff1f64c78768fdb4cba..91827bc01932435f3e7317e9767203919cd00916 100644 (file)
@@ -635,7 +635,12 @@ class userManagement extends plugin
       }
       return ($display);
     }
-      
+    
+    /* Check if there is a snapshot dialog open */
+    if($str = $this->showSnapshotDialog($this->DivListUsers->selectedBase,get_people_ou())){
+      return($str);
+    }
+  
     /* Return rendered main page */
         /* Display dialog with system list */
     $this->DivListUsers->parent = $this;
@@ -809,63 +814,6 @@ class userManagement extends plugin
   {
     /* Handle divlist filter && department selection*/
     $this->DivListUsers->save_object();
-
-    /* check for posts */
-    $once = true;
-    foreach($_POST as $name => $value){
-
-      /* Create a new snapshot, display a dialog */
-      if(preg_match("/^CreateSnapShot_/",$name) && $once){
-        $once = false;
-        $entry = preg_replace("/^CreateSnapShot_/","",$name);
-        $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
-        $this->usertab = new SnapShotDialog($this->config,$entry,$this);
-      }
-
-      /* Restore a snapshot, display a dialog with all snapshots of the current object */
-      if(preg_match("/^RestoreSnapShot_/",$name) && $once){
-        $once = false;
-        $entry = preg_replace("/^RestoreSnapShot_/","",$name);
-        $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
-        $this->usertab = new SnapShotDialog($this->config,$entry,$this);
-        $this->usertab->Restore = true;
-      }
-
-      /* Restore one of the already deleted objects */
-      if(preg_match("/^RestoreDeletedSnapShot_/",$name) && $once){
-        $once = false;
-        $entry = get_people_ou().$this->DivListUsers->selectedBase;
-        $this->usertab = new SnapShotDialog($this->config,$entry,$this);
-        $this->usertab->Restore      = true;
-        $this->usertab->DeletedOnes  = true;
-      }
-    }
-
-    /* Create a new snapshot requested, check
-       the given attributes and create the snapshot*/
-    if(isset($_POST['CreateSnapshot'])){
-      $this->usertab->save_object();
-      $msgs = $this->usertab->check();
-      if(count($msgs)){
-        foreach($msgs as $msg){
-          print_red($msg);
-        }
-      }else{
-        $this->dn =  $this->usertab->dn;
-        $this->create_snapshot("snapshot",$this->usertab->CurrentDescription);
-        $this->usertab = NULL;
-      }
-    }
-
-    /* Restore is requested, restore the object with the posted dn .*/
-    if((isset($_POST['RestoreSnapshot'])) && (isset($_POST['SnapShot']))){
-      $entry =trim($_POST['SnapShot']);
-      if(!empty($entry)){
-        $entry = base64_decode($entry);
-        $this->restore_snapshot($entry);
-        $this->usertab = NULL;
-      }
-    }
   }
 
   /* A set of disabled and therefore overloaded functions. They are