From: hickert Date: Tue, 13 Jun 2006 09:30:24 +0000 (+0000) Subject: Added snapshot to groups && fixed restore dialog X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ce2215bfd43512b02b7e5180bfe62a6d7dbda2ec;p=gosa.git Added snapshot to groups && fixed restore dialog git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3798 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/groups/class_divListGroup.inc b/plugins/admin/groups/class_divListGroup.inc index f8139ab58..30b1df8a4 100644 --- a/plugins/admin/groups/class_divListGroup.inc +++ b/plugins/admin/groups/class_divListGroup.inc @@ -48,7 +48,7 @@ class divListGroup extends MultiSelectWindow $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); $this->AddHeader(array("string"=>_("Groupname / Department"))); $this->AddHeader(array("string"=>_("Properties"),"attach"=>"style='width:136px;'")); - $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:80px;border-right:0px;'")); + $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:110px;border-right:0px;'")); /* Text ,Value ,Name ,Is selected */ $this->AddCheckBox("ShowPrimaryGroups", _("Select to see groups that are primary groups of users"), _("Show primary groups"), true); @@ -67,6 +67,26 @@ 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, @@ -94,13 +114,21 @@ class divListGroup extends MultiSelectWindow "  ". "  ". "  ". - "  ". - "  ". + "  "; + + + if($this->parent->snapshotEnabled()){ + $listhead .= " ". + "  "; + } + + $listhead.="  ". $Copy_Paste. "  ". _("Base")." ". - "  ". + "  ". ""; $this->SetListHeader($listhead); @@ -138,25 +166,26 @@ class divListGroup extends MultiSelectWindow // Space $empty = ""; - /* Create action icons - copy & paste icons */ - $actions = ""; - if($this->parent->CopyPasteHandler){ - $actions.= " "; - $actions.= " "; - } - $actions.= ""; - $actions.= ""; - // User and Template Images $editlink = "%s"; // Test Every Entry and generate divlist Array foreach($groups as $key => $val){ + + /* Create action icons - copy & paste icons */ + $actions = $this->GetSnapShotActions($val['dn']); + if($this->parent->CopyPasteHandler){ + $actions.= " "; + $actions.= " "; + } + $actions.= ""; + $actions.= ""; + $posix=$mail=$samba=$appl=$phone=$enviro=$empty; @@ -185,7 +214,7 @@ class divListGroup extends MultiSelectWindow $field1 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title); $field3 = array("string" => preg_replace("/%KEY%/", $key, $posix." ".$enviro." ".$mail." ".$samba." ".$appl." ".$phone), "attach" => "style='width:136px;'"); - $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80px;border-right:0px;text-align:right;'"); + $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:110px;border-right:0px;text-align:right;'"); $this->AddElement(array($field1,$field2,$field3,$field4)); } diff --git a/plugins/admin/groups/class_groupManagement.inc b/plugins/admin/groups/class_groupManagement.inc index 30309740d..305fd6a9c 100644 --- a/plugins/admin/groups/class_groupManagement.inc +++ b/plugins/admin/groups/class_groupManagement.inc @@ -306,7 +306,9 @@ class groupManagement extends plugin /* Cancel dialogs */ if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){ - del_lock ($this->grouptab->dn); + if(isset($this->grouptab->dn)){ + del_lock ($this->grouptab->dn); + } unset ($this->grouptab); $this->grouptab= NULL; unset($_SESSION['objectinfo']); @@ -322,16 +324,18 @@ class groupManagement extends plugin $display= $this->grouptab->execute(); /* Don't show buttons if tab dialog requests this */ - if (!$this->grouptab->by_object[$this->grouptab->current]->dialog){ - $display.= "

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

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

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

"; } return ($display); } @@ -518,6 +522,61 @@ 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_SnapShotDialog.inc b/plugins/admin/systems/class_SnapShotDialog.inc index 0720d7081..213bde0ae 100755 --- a/plugins/admin/systems/class_SnapShotDialog.inc +++ b/plugins/admin/systems/class_SnapShotDialog.inc @@ -52,6 +52,7 @@ class SnapShotDialog extends plugin $res[base64_encode($entry['dn'])] = $date." - ".$data; } $smarty->assign("SnapShots",$res); + $smarty->assign("CountSnapShots",count($res)); } $smarty->assign("RestoreMode",$this->Restore); diff --git a/plugins/admin/systems/snapshotdialog.tpl b/plugins/admin/systems/snapshotdialog.tpl index 3495d77cb..e3d103559 100755 --- a/plugins/admin/systems/snapshotdialog.tpl +++ b/plugins/admin/systems/snapshotdialog.tpl @@ -8,21 +8,35 @@


-{t}You will be able to restore from{/t} + + {if $CountSnapShots!=0} + {t}You will be able to restore from{/t} + {else} + {t}There are no available snapshots.{/t} + {/if}


- @@ -31,7 +45,7 @@

 

- +  

{t}Choose a snapshot and click continue, to restore the snapshot.{/t} + + {if $CountSnapShots==0} + {t}There is no snapshot available that could be restored.{/t} + {else} + {t}Choose a snapshot and click continue, to restore the snapshot.{/t} + {/if}
- + {if $CountSnapShots==0} disabled + + {else} + + {html_options options=$SnapShots} + {/if}