Code

Fixed snap shot dialog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 3 Nov 2006 11:30:11 +0000 (11:30 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 3 Nov 2006 11:30:11 +0000 (11:30 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5007 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_SnapShotDialog.inc
include/class_plugin.inc
plugins/admin/users/main.inc

index 957a0077c72c16137c853273678a55657b2914fc..4fc900d01c8d5296964e5f0a64ec5e0c2b674a17 100755 (executable)
@@ -15,13 +15,23 @@ class SnapShotDialog extends plugin
        var $del_dn= "";
        var $ui;
        var $acl;
+  var $dns = array();
+  var $snap_shot_bases = array();
+
        
        function SnapShotDialog($config,$dn,$parent)
        {
-               plugin::plugin($config,$dn);
-               $this->parent   = $parent;
-               $this->ui               = get_userinfo();
+    plugin::plugin($config,$dn);
+    $this->parent      = $parent;
+               $this->ui                 = get_userinfo();
        }
+
+  
+  /* Show deleted snapshots from these bases */
+  function set_snapshot_bases($bases)
+  {
+    $this->snap_shot_bases = $bases;
+  }
        
        
        /* Display snapshot dialog */
@@ -29,7 +39,7 @@ class SnapShotDialog extends plugin
        {
                plugin::execute();
                $smarty = get_smarty();
-       
+
                $once = true;
                foreach($_POST as $name => $value){
                        if((preg_match("/^RemoveSnapShot_/",$name)) && ($once)){
@@ -38,10 +48,6 @@ class SnapShotDialog extends plugin
                                $entry = preg_replace("/^RemoveSnapShot_/","",$name);
                                $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
 
-                               $acl                    = get_permissions ($entry, $this->ui->subtreeACL);
-        $this->acl             = get_module_permission($acl, "snapshot", $entry );
-
-
         $this->del_dn  = $entry;
         $smarty= get_smarty();
         $smarty->assign("intro", sprintf(_("You're about to delete the snapshot '%s'."), @LDAP::fix($this->del_dn)));
@@ -66,14 +72,14 @@ class SnapShotDialog extends plugin
                        /* Should we only display all snapshots of already deleted objects 
                 or the snapshots for the given object dn */
                        $res = array();
+                       $tmp = array();
                        if($this->display_all_removed_objects){
-                               if(is_array($this->dn)){
-                                       $tmp = array();
-                                       foreach($this->dn as $dn){
+                               if(count($this->snap_shot_bases)){
+                                       foreach($this->snap_shot_bases as $dn){
                                                $tmp = array_merge($tmp,$this->getAllDeletedSnapshots($dn,true));
                                        }
                                }else{
-                                       $tmp = $this->getAllDeletedSnapshots($this->dn,true);
+                                       $tmp = $this->getAllDeletedSnapshots($this->snap_shot_bases,true);
                                }
                        }else{
                                $tmp = $this->Available_SnapsShots($this->dn,true);
index af92fbe4f3947467e8386f1f63ffb146e00301d8..9f92c624b90d15f7ada4db1823710116c196d1c1 100644 (file)
@@ -1123,15 +1123,18 @@ class plugin
 
   function remove_snapshot($dn)
   {
-    $ui   = get_userinfo();
-
-    if($this->acl_is_removeable()){
+    $ui       = get_userinfo();
+    $old_dn   = $this->dn; 
+    $this->dn = $dn;
+    
+    if($this->acl_is_removeable() && $this->acl_is_createable()){
       $ldap = $this->config->get_ldap_link();
       $ldap->cd($this->config->current['BASE']);
       $ldap->rmdir_recursive($dn);
     }else{
       print_red (_("You are not allowed to delete this snapshot!"));
     }
+    $this->dn = $old_dn;
   }
 
 
@@ -1352,7 +1355,8 @@ class plugin
       /* Restore one of the already deleted objects */
       if(preg_match("/^RestoreDeletedSnapShot_/",$name) && $once){
         $once = false;
-        $this->snapDialog = new SnapShotDialog($this->config,$baseSuffixe,$this);
+        $this->snapDialog = new SnapShotDialog($this->config,"",$this);
+        $this->snapDialog->set_snapshot_bases($baseSuffixe);
         $this->snapDialog->display_restore_dialog      = true;
         $this->snapDialog->display_all_removed_objects  = true;
       }
index 128417a0178c8d4b739b7aca6ffab4b624f22bf1..d545835f7cc0355122f67a8573b96802669c0e5d 100644 (file)
@@ -30,6 +30,7 @@ if ($remove_lock){
   if (!isset($_SESSION['userManagement']) ||
      (isset($_GET['reset']) && $_GET['reset'] == 1)){
     $_SESSION['userManagement']= new userManagement ($config, $_SESSION['ui']);
+    $_SESSION['userManagement']->set_acl_category("users");
   }
   $userManagement= $_SESSION['userManagement'];
   $userManagement->save_object();