Marius Burkard
2016-04-20 4569cae57f127afd093794310ccd290d2d9fdf36
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) " .
aa365c 65                     "VALUES (?, ?, 'backup_restore_mail', ?, 'pending','')";
cc7a82 66                     $app->db->query($sql, $this->form->dataRecord['server_id'], time(), $backup_id);
f17718 67                 } else {
FS 68                     $error .= $wb['restore_pending_txt'];
69                 }
634132 70             }    
D 71             
72             if($_GET['backup_action'] == 'delete_mail' && $backup_id > 0) {
73                 $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_delete_mail' AND action_param = '$backup_id'";
74                 $tmp = $app->db->queryOneRecord($sql);
75                 if($tmp['number'] == 0) {
76                     $message .= $wb['delete_info_txt'];
77                     $sql =     "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " .
aa365c 78                     "VALUES (?, ?, 'backup_delete_mail, ?, 'pending', '')";
R 79                     $app->db->query($sql, $this->form->dataRecord['server_id'], time(), $backup_id);
634132 80                 } else {
D 81                     $error .= $wb['delete_pending_txt'];
82                 }
f17718 83             }                
FS 84         }
85                 
86         //* Get the data
cc7a82 87         $sql = "SELECT * FROM mail_backup WHERE mailuser_id = ? ORDER BY tstamp DESC";
MC 88         $records = $app->db->queryAllRecords($sql, $this->form->id);
f17718 89         $bgcolor = "#FFFFFF";
FS 90         if(is_array($records)) {
91             foreach($records as $rec) {
92                 // Change of color
93                 $bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
94                 $rec["bgcolor"] = $bgcolor;
95                 $rec['date'] = date($app->lng('conf_format_datetime'),$rec['tstamp']);
96                 $rec['backup_type'] = $wb[('backup_type_'.$rec['backup_type'])];
97321a 97                 $rec['filesize'] = $app->functions->formatBytes($rec['filesize']);
f17718 98                 $records_new[] = $rec;
FS 99             }
100         }
101
102         $listTpl->setLoop('records',@$records_new);
103
104         $listTpl->setVar('parent_id',$this->form->id);
105         $listTpl->setVar('msg',$message);
106         $listTpl->setVar('error',$error);
107
108         // Setting Returnto information in the session
109         $list_name = 'backup_list';
110         $_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id;
111         $_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"];
112         $_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"];
113         $_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"];
114         $_SESSION["s"]["form"]["return_to"] = $list_name;
115         return $listTpl->grab();
116     } // end function
117 } // end class
118
119 ?>