From 9b4218828c153aea81c47788f443153f3b04192a Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 13 Jun 2006 10:54:28 +0000 Subject: [PATCH] Moved snapshot management into plugin git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3799 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_MultiSelectWindow.inc | 21 ++++++ include/class_plugin.inc | 70 +++++++++++++++++++ plugins/admin/groups/class_divListGroup.inc | 20 ------ .../admin/groups/class_groupManagement.inc | 61 ++-------------- plugins/admin/systems/class_divListSystem.inc | 19 ----- .../admin/systems/class_systemManagement.inc | 61 ++-------------- plugins/admin/systems/snapshotdialog.tpl | 4 +- plugins/admin/users/class_divListUsers.inc | 19 ----- plugins/admin/users/class_userManagement.inc | 64 ++--------------- 9 files changed, 110 insertions(+), 229 deletions(-) diff --git a/include/class_MultiSelectWindow.inc b/include/class_MultiSelectWindow.inc index 00d49d6d5..8481095f0 100644 --- a/include/class_MultiSelectWindow.inc +++ b/include/class_MultiSelectWindow.inc @@ -483,6 +483,27 @@ class MultiSelectWindow{ } + + function GetSnapShotActions($dn) + { + $str = ""; + + if($this->parent->snapshotEnabled()){ + + $str .=" "; + + if(count($this->parent->Available_SnapsShots($dn))){ + $str .=" "; + }else{ + $str.= " "; + } + } + return($str); + } + + /* this function adds the sub-departments of the current tree to the list */ function AddDepartments($base = false,$numtabs = 3) { diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 2a34d2c55..a80b8511b 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -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: ?> diff --git a/plugins/admin/groups/class_divListGroup.inc b/plugins/admin/groups/class_divListGroup.inc index 30b1df8a4..13e97e2ac 100644 --- a/plugins/admin/groups/class_divListGroup.inc +++ b/plugins/admin/groups/class_divListGroup.inc @@ -67,26 +67,6 @@ class divListGroup extends MultiSelectWindow } - function GetSnapShotActions($dn) - { - $str = ""; - - if($this->parent->snapshotEnabled()){ - - $str .=" "; - - if(count($this->parent->Available_SnapsShots($dn))){ - $str .=" "; - }else{ - $str.= " "; - } - } - return($str); - } - - function GenHeader() { /* Prepare departments, diff --git a/plugins/admin/groups/class_groupManagement.inc b/plugins/admin/groups/class_groupManagement.inc index 305fd6a9c..69ca59c01 100644 --- a/plugins/admin/groups/class_groupManagement.inc +++ b/plugins/admin/groups/class_groupManagement.inc @@ -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; - } - } } diff --git a/plugins/admin/systems/class_divListSystem.inc b/plugins/admin/systems/class_divListSystem.inc index 008c519f8..3cdd8cb9e 100644 --- a/plugins/admin/systems/class_divListSystem.inc +++ b/plugins/admin/systems/class_divListSystem.inc @@ -126,25 +126,6 @@ class divListSystem extends MultiSelectWindow } - function GetSnapShotActions($dn) - { - $str = ""; - - if($this->parent->snapshotEnabled()){ - - $str .=" "; - - if(count($this->parent->Available_SnapsShots($dn))){ - $str .=" "; - }else{ - $str.= " "; - } - } - return($str); - } - function setEntries($terminals) { $img1 = "C"; diff --git a/plugins/admin/systems/class_systemManagement.inc b/plugins/admin/systems/class_systemManagement.inc index 8b945d551..a94d4b4d5 100644 --- a/plugins/admin/systems/class_systemManagement.inc +++ b/plugins/admin/systems/class_systemManagement.inc @@ -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; - } - } } diff --git a/plugins/admin/systems/snapshotdialog.tpl b/plugins/admin/systems/snapshotdialog.tpl index e3d103559..a285725a2 100755 --- a/plugins/admin/systems/snapshotdialog.tpl +++ b/plugins/admin/systems/snapshotdialog.tpl @@ -47,7 +47,7 @@
  - +

{else} @@ -94,6 +94,6 @@
  - +

{/if} diff --git a/plugins/admin/users/class_divListUsers.inc b/plugins/admin/users/class_divListUsers.inc index 55efed9ee..d9e7d434e 100644 --- a/plugins/admin/users/class_divListUsers.inc +++ b/plugins/admin/users/class_divListUsers.inc @@ -66,25 +66,6 @@ class divListUsers extends MultiSelectWindow $this->AddRegex ("Regex", _("Display users matching"),"*" , true); } - function GetSnapShotActions($dn) - { - $str = ""; - - if($this->parent->snapshotEnabled()){ - - $str .=" "; - - if(count($this->parent->Available_SnapsShots($dn))){ - $str .=" "; - }else{ - $str.= " "; - } - } - return($str); - } - function GenHeader() { diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index ebe79b496..91827bc01 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -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 -- 2.30.2