dcac0b80c72558c5aa059f1d8aa1d538c80d4f0d
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;
14 function SnapShotDialog($config,$dn,$parent)
15 {
16 plugin::plugin($config,$dn);
17 $this->parent = $parent;
18 }
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 if(is_array($this->dn)){
35 $tmp = array();
36 foreach($this->dn as $dn){
37 $tmp = array_merge($tmp,$this->getAllDeletedSnapshots($dn,true));
38 }
39 }else{
40 $tmp = $this->getAllDeletedSnapshots($this->dn,true);
41 }
42 }else{
43 $tmp = $this->Available_SnapsShots($this->dn,true);
44 }
46 /* Walk through all entries and setup the display text */
47 foreach($tmp as $key => $entry){
49 $data = $entry['description'][0];
50 $date = date("d.m.Y H.i.s",preg_replace("/\-.*$/","",$entry['gosaSnapshotTimestamp'][0]));
51 if($this->DeletedOnes){
52 $data.= " - ".$entry['gosaSnapshotDN'][0];
53 }
55 if(strlen($data) > 83){
56 $data= substr($data,0,80)." ...";
57 }
59 $res[base64_encode($entry['dn'])] = $date." - ".$data;
60 }
61 $smarty->assign("SnapShots",$res);
62 $smarty->assign("CountSnapShots",count($res));
63 }
65 $smarty->assign("RestoreMode",$this->Restore);
66 $smarty->assign("CurrentDate",date("d.m.Y H:i"));
67 $smarty->assign("CurrentDN",$this->dn);
68 $smarty->assign("CurrentDescription",$this->CurrentDescription);
69 return($smarty->fetch(get_template_path("snapshotdialog.tpl",TRUE,dirname(__FILE__))));
70 }
73 function check()
74 {
75 $message = plugin::check();
76 if(!$this->Restore){
77 if(empty($this->CurrentDescription)){
78 $message[] = _("Please specify a valid description for this snapshot.");
79 }
80 }
81 return($message);
82 }
85 function save_object()
86 {
87 plugin::save_object();
88 foreach($this->attributes as $name){
89 if(isset($_POST[$name])){
90 $this->$name = stripslashes($_POST[$name]);
91 }
92 }
93 }
94 }
96 ?>