Marius Cramer
2015-08-06 37b29231e47a0c4458dc1c15d98588f16f07e1e2
commit | author | age
f17718 1 <?php
FS 2
3 /*
4 Copyright (c) 2013, Florian Schaal, info@schaal-24.de
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 class plugin_backuplist_mail extends plugin_base {
32
33     var $module;
34     var $form;
35     var $tab;
36     var $record_id;
37     var $formdef;
38     var $options;
39
40     function onShow() {
41         global $app;
97321a 42         
D 43         $app->uses('functions');
44         
f17718 45         $listTpl = new tpl;
FS 46         $listTpl->newTemplate('templates/mail_user_backup_list.htm');
47                 
48         //* Loading language file
49         $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_mail_backup_list.lng";
50         include($lng_file);
51         $listTpl->setVar($wb);
52
53         $message = '';
54         $error = '';
55
56         if(isset($_GET['backup_action'])) {
57             $backup_id = $app->functions->intval($_GET['backup_id']);
cc7a82 58
d2c52b 59             if($_GET['backup_action'] == 'restore_mail' && $backup_id > 0) {
cc7a82 60                 $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_restore_mail' AND action_param = ?";
MC 61                 $tmp = $app->db->queryOneRecord($sql, $backup_id);
f17718 62                 if($tmp['number'] == 0) {
FS 63                     $message .= $wb['restore_info_txt'];
64                     $sql =     "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " .
cc7a82 65                     "VALUES (?, ? 'backup_restore_mail', ?, 'pending','')";
MC 66                     $app->db->query($sql, $this->form->dataRecord['server_id'], time(), $backup_id);
f17718 67                 } else {
FS 68                     $error .= $wb['restore_pending_txt'];
69                 }
70             }                
71         }
72                 
73         //* Get the data
cc7a82 74         $sql = "SELECT * FROM mail_backup WHERE mailuser_id = ? ORDER BY tstamp DESC";
MC 75         $records = $app->db->queryAllRecords($sql, $this->form->id);
f17718 76         $bgcolor = "#FFFFFF";
FS 77         if(is_array($records)) {
78             foreach($records as $rec) {
79                 // Change of color
80                 $bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
81                 $rec["bgcolor"] = $bgcolor;
82                 $rec['date'] = date($app->lng('conf_format_datetime'),$rec['tstamp']);
83                 $rec['backup_type'] = $wb[('backup_type_'.$rec['backup_type'])];
97321a 84                 $rec['filesize'] = $app->functions->formatBytes($rec['filesize']);
f17718 85                 $records_new[] = $rec;
FS 86             }
87         }
88
89         $listTpl->setLoop('records',@$records_new);
90
91         $listTpl->setVar('parent_id',$this->form->id);
92         $listTpl->setVar('msg',$message);
93         $listTpl->setVar('error',$error);
94
95         // Setting Returnto information in the session
96         $list_name = 'backup_list';
97         $_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id;
98         $_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"];
99         $_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"];
100         $_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"];
101         $_SESSION["s"]["form"]["return_to"] = $list_name;
102         return $listTpl->grab();
103     } // end function
104 } // end class
105
106 ?>