Code

0720d70810653e78acade689f69398630f201c43
[gosa.git] / plugins / admin / systems / class_SnapShotDialog.inc
1 <?php
3 /* Snap shot dialog class */
4 class SnapShotDialog extends plugin 
5 {
6         var $config;
7         var $attributes                 = array("CurrentDescription");
8         var $CurrentDescription = "";
9         var $parent                             = NULL;
10         var $Restore                    = false;                /* Defines the restore mode */
11         var $DeletedOnes                = false;                /* Specifies which objects will be listed */    
12         var $dialog                             = true;
13         
14         function SnapShotDialog($config,$dn,$parent)
15         {
16                 plugin::plugin($config,$dn);
17                 $this->parent = $parent;
18         }
19         
20         
21         /* Display snapshot dialog */
22         function execute()
23         {
24                 plugin::execute();
25                 $smarty = get_smarty();
27                 /* We must restore a snapshot, so get snapshots  */
28                 if($this->Restore){
30                         /* Should we only display all snapshots of already deleted objects 
31                 or the snapshots for the given object dn */
32                         $res = array();
33                         if($this->DeletedOnes){
34                                 $tmp = $this->getAllDeletedSnapshots($this->dn,true);
35                         }else{
36                                 $tmp = $this->Available_SnapsShots($this->dn,true);
37                         }
38                 
39                         /* Walk through all entries and setup the display text */
40                         foreach($tmp as $key => $entry){
41                         
42                                 $data = $entry['description'][0];
43                                 $date = date("d.m.Y H.i.s",preg_replace("/\-.*$/","",$entry['gosaSnapshotTimestamp'][0]));
44                                 if($this->DeletedOnes){
45                                         $data.= " - ".$entry['gosaSnapshotDN'][0];
46                                 }
47         
48                                 if(strlen($data) > 83){
49                                         $data= substr($data,0,80)." ...";
50                                 }
51         
52                                 $res[base64_encode($entry['dn'])] = $date." - ".$data;
53                         }
54                         $smarty->assign("SnapShots",$res);
55                 }
57                 $smarty->assign("RestoreMode",$this->Restore);
58                 $smarty->assign("CurrentDate",date("d.m.Y H:i"));
59                 $smarty->assign("CurrentDN",$this->dn);
60                 $smarty->assign("CurrentDescription",$this->CurrentDescription);
61                 return($smarty->fetch(get_template_path("snapshotdialog.tpl",TRUE,dirname(__FILE__))));
62         }
65         function check()
66         {
67                 $message = plugin::check();
68                 if(!$this->Restore){
69                         if(empty($this->CurrentDescription)){
70                                 $message[]  = _("Please specify a valid description for this snapshot.");
71                         }
72                 }
73                 return($message);
74         }
77         function save_object()
78         {       
79                 plugin::save_object();
80                 foreach($this->attributes as $name){
81                         if(isset($_POST[$name])){
82                                 $this->$name = stripslashes($_POST[$name]);
83                         }
84                 }
85         }
86 }
88 ?>