From af6e12804eee17c82fb9bd79564f0ff0448a0da3 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 13 Jun 2006 08:36:10 +0000 Subject: [PATCH] Added snapshot to users management git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3796 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/class_SnapShotDialog.inc | 2 +- plugins/admin/systems/class_divListSystem.inc | 4 +- plugins/admin/users/class_divListUsers.inc | 66 ++++++++++----- plugins/admin/users/class_userManagement.inc | 82 ++++++++++++++++--- 4 files changed, 121 insertions(+), 33 deletions(-) diff --git a/plugins/admin/systems/class_SnapShotDialog.inc b/plugins/admin/systems/class_SnapShotDialog.inc index 4da63c0b5..0720d7081 100755 --- a/plugins/admin/systems/class_SnapShotDialog.inc +++ b/plugins/admin/systems/class_SnapShotDialog.inc @@ -9,7 +9,7 @@ class SnapShotDialog extends plugin var $parent = NULL; var $Restore = false; /* Defines the restore mode */ var $DeletedOnes = false; /* Specifies which objects will be listed */ - + var $dialog = true; function SnapShotDialog($config,$dn,$parent) { diff --git a/plugins/admin/systems/class_divListSystem.inc b/plugins/admin/systems/class_divListSystem.inc index 7b0097267..008c519f8 100644 --- a/plugins/admin/systems/class_divListSystem.inc +++ b/plugins/admin/systems/class_divListSystem.inc @@ -95,7 +95,7 @@ class divListSystem extends MultiSelectWindow if($this->parent->snapshotEnabled()){ $listhead .= " ". + title='"._("Restore snapshopts of already deleted objects")."' alt='"._("Restore")."' name='RestoreDeletedSnapShot'>". "  "; } @@ -133,7 +133,7 @@ class divListSystem extends MultiSelectWindow if($this->parent->snapshotEnabled()){ $str .=" "; + alt='"._("Create snapshot")."' name='CreateSnapShot_".base64_encode($dn)."' title='"._("Create a new snapshot from this object")."'> "; if(count($this->parent->Available_SnapsShots($dn))){ $str .="AddHeader(array("string"=>" ", "attach"=>"style='width:20px;'")); $this->AddHeader(array("string"=>_("Username")." / "._("Department"))); $this->AddHeader(array("string"=>_("Properties"), "attach" => "style='width:152px;'")); - $this->AddHeader(array("string"=>_("Actions"), "attach" => "style='width:102px;border-right:0px;text-align:right;'")); + $this->AddHeader(array("string"=>_("Actions"), "attach" => "style='width:132px;border-right:0px;text-align:right;'")); $this->AddCheckBox("ShowTemplates" ,_("Select to see template pseudo users") ,_("Show templates") , false); $this->AddCheckBox("ShowFunctionalUsers",_("Select to see users that have only a GOsa object"),_("Show functional users") , true); @@ -66,6 +66,26 @@ 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() { /* Prepare departments, @@ -97,8 +117,15 @@ class divListUsers extends MultiSelectWindow title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ". "  ". - "  ". - "  "; + + if($this->parent->snapshotEnabled()){ + $listhead .= " ". + "  "; + } + + $listhead .= "  ". "  ". @@ -132,21 +159,6 @@ class divListUsers extends MultiSelectWindow $tplimg = "Template"; $editlink = "%s"; - /* Create action icons */ - $action = ""; - if($this->parent->CopyPasteHandler){ - $action .= " "; - $action.= " "; - } - $action.= ""; - $action.= ""; - $action.= ""; - /* Possilbe objectClass image combinations */ $possibleAccounts = array( "posixAccount" => array("VAR"=>"posix" ,"IMG"=>"posiximg"), @@ -211,6 +223,22 @@ class divListUsers extends MultiSelectWindow // Test Every Entry and generate divlist Array foreach($list as $key => $val){ + /* Create action icons */ + $action = $this->GetSnapShotActions($val['dn']); + if($this->parent->CopyPasteHandler){ + $action .= " "; + $action.= " "; + } + $action.= ""; + $action.= ""; + $action.= ""; + + /* Create phonaccopunt informationm, if conencted && is phoneAccount */ $connected = ""; // This string represents timestamp or offline status $ip_port = ""; // String that will represent ip : port of the connected phone @@ -281,7 +309,7 @@ class divListUsers extends MultiSelectWindow $field2 = array("string" => sprintf($editlink,$key,$display).$ip_port, "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); $field3 = array("string" => $UseImg, "attach" => "style='width:152px;'"); $field4 = array("string" => $s_img_create_from_template.preg_replace("/%KEY%/", "$key", $action), - "attach" => "style='width:102px;border-right:0px; text-align:right;'"); + "attach" => "style='width:132px;border-right:0px; text-align:right;'"); /* Add to list */ $add = array($field1,$field2,$field3,$field4); $this->AddElement($add); diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index 362245e05..517ef7887 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -620,16 +620,18 @@ class userManagement extends plugin $display= $this->usertab->execute(); /* Don't show buttons if tab dialog requests this */ - if (!$this->usertab->by_object[$this->usertab->current]->dialog){ - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if ($this->dn != "new"){ - $display.= "\n"; + if(isset($this->usertab->by_object)){ + if (!$this->usertab->by_object[$this->usertab->current]->dialog){ + $display.= "

\n"; + $display.= "\n"; $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; } - $display.= "\n"; - $display.= "

"; } return ($display); } @@ -777,8 +779,8 @@ class userManagement extends plugin } /* Copy selected object - Create a new empty object and the current selected object. - Send both to copy&paste class*/ + Create a new empty object and the current selected object. + Send both to copy&paste class*/ if($s_action == "copy"){ $this->CopyPasteHandler->Clear(); $dn= $this->list[trim($s_entry)]['dn']; @@ -791,7 +793,7 @@ class userManagement extends plugin } /* Cut selected object. - Open user object and send it to the copy & paste handler */ + Open user object and send it to the copy & paste handler */ if($s_action == "cut"){ $this->CopyPasteHandler->Clear(); $dn= $this->list[trim($s_entry)]['dn']; @@ -807,6 +809,64 @@ 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; + echo $this->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