|
| 1 | +<?php |
| 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; |
| 42 | + $listTpl = new tpl; |
| 43 | + $listTpl->newTemplate('templates/mail_user_backup_list.htm'); |
| 44 | + |
| 45 | + //* Loading language file |
| 46 | + $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_mail_backup_list.lng"; |
| 47 | + include($lng_file); |
| 48 | + $listTpl->setVar($wb); |
| 49 | + |
| 50 | + $message = ''; |
| 51 | + $error = ''; |
| 52 | + |
| 53 | + if(isset($_GET['backup_action'])) { |
| 54 | + $backup_id = $app->functions->intval($_GET['backup_id']); |
| 55 | +/* |
| 56 | + if($_GET['backup_action'] == 'download' && $backup_id > 0) { |
| 57 | + $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_download' AND action_param = '$backup_id'"; |
| 58 | + $tmp = $app->db->queryOneRecord($sql); |
| 59 | + if($tmp['number'] == 0) { |
| 60 | + $message .= $wb['download_info_txt']; |
| 61 | + $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . |
| 62 | + "VALUES (". |
| 63 | + (int)$this->form->dataRecord['server_id'] . ", " . |
| 64 | + time() . ", " . |
| 65 | + "'backup_download', " . |
| 66 | + "'".$backup_id."', " . |
| 67 | + "'pending', " . |
| 68 | + "''" . |
| 69 | + ")"; |
| 70 | + $app->db->query($sql); |
| 71 | + } else { |
| 72 | + $error .= $wb['download_pending_txt']; |
| 73 | + } |
| 74 | + } |
| 75 | +*/ |
| 76 | + if($_GET['backup_action'] == 'restore' && $backup_id > 0) { |
| 77 | + $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_restore' AND action_param = '$backup_id'"; |
| 78 | + $tmp = $app->db->queryOneRecord($sql); |
| 79 | + if($tmp['number'] == 0) { |
| 80 | + $message .= $wb['restore_info_txt']; |
| 81 | + $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . |
| 82 | + "VALUES (". |
| 83 | + (int)$this->form->dataRecord['server_id'] . ", " . |
| 84 | + time() . ", " . |
| 85 | + "'backup_restore', " . |
| 86 | + "'".$backup_id."', " . |
| 87 | + "'pending', " . |
| 88 | + "''" . |
| 89 | + ")"; |
| 90 | + $app->db->query($sql); |
| 91 | + } else { |
| 92 | + $error .= $wb['restore_pending_txt']; |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + //* Get the data |
| 98 | + $sql = "SELECT * FROM mail_backup WHERE mailuser_id = ".$this->form->id." ORDER BY tstamp DESC"; |
| 99 | + $records = $app->db->queryAllRecords($sql); |
| 100 | + $bgcolor = "#FFFFFF"; |
| 101 | + if(is_array($records)) { |
| 102 | + foreach($records as $rec) { |
| 103 | + // Change of color |
| 104 | + $bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF"; |
| 105 | + $rec["bgcolor"] = $bgcolor; |
| 106 | + $rec['date'] = date($app->lng('conf_format_datetime'),$rec['tstamp']); |
| 107 | + $rec['backup_type'] = $wb[('backup_type_'.$rec['backup_type'])]; |
| 108 | + $records_new[] = $rec; |
| 109 | + } |
| 110 | + } |
| 111 | + |
| 112 | + $listTpl->setLoop('records',@$records_new); |
| 113 | + |
| 114 | + $listTpl->setVar('parent_id',$this->form->id); |
| 115 | + $listTpl->setVar('msg',$message); |
| 116 | + $listTpl->setVar('error',$error); |
| 117 | + |
| 118 | + // Setting Returnto information in the session |
| 119 | + $list_name = 'backup_list'; |
| 120 | + $_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id; |
| 121 | + $_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"]; |
| 122 | + $_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"]; |
| 123 | + $_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"]; |
| 124 | + $_SESSION["s"]["form"]["return_to"] = $list_name; |
| 125 | + return $listTpl->grab(); |
| 126 | + } // end function |
| 127 | +} // end class |
| 128 | + |
| 129 | +?> |
0 commit comments