|
50 | 50 |
|
51 | 51 | $old_record = $app->db->queryOneRecord('SELECT * FROM ?? WHERE ??=?', $record['dbtable'], $dbidx[0], $dbidx[1]); |
52 | 52 |
|
53 | | -if (is_array($old_record)) { |
54 | | - if(!$data = unserialize(stripslashes($record['data']))) { |
55 | | - $data = unserialize($record['data']); |
| 53 | +if($record['action'] === 'u') { |
| 54 | + if (is_array($old_record)) { |
| 55 | + if(!$data = unserialize(stripslashes($record['data']))) { |
| 56 | + $data = unserialize($record['data']); |
| 57 | + } |
| 58 | + |
| 59 | + $new_record = $data['old']; |
| 60 | + |
| 61 | + $app->db->datalogUpdate($record['dbtable'], $new_record, $dbidx[0], $dbidx[1]); |
| 62 | + |
| 63 | + $app->tpl->setVar('success', true); |
| 64 | + } else { |
| 65 | + $app->tpl->setVar('success', false); |
56 | 66 | } |
| 67 | +} elseif($record['action'] === 'd') { |
| 68 | + if(is_array($old_record)) { |
| 69 | + $app->tpl->setVar('success', false); |
| 70 | + $app->tpl->setVar('error_txt', $wb['error_undelete_txt']); |
| 71 | + } else { |
| 72 | + if(!$data = unserialize(stripslashes($record['data']))) { |
| 73 | + $data = unserialize($record['data']); |
| 74 | + } |
57 | 75 |
|
58 | | - $new_record = $data['old']; |
| 76 | + $new_record = $data['old']; |
| 77 | + /* TODO: maybe check some data, e. g. server_id -> server still there?, sys_groupid -> sys_group/sys_user still there? */ |
59 | 78 |
|
60 | | - $app->db->datalogUpdate($record['dbtable'], $new_record, $dbidx[0], $dbidx[1]); |
| 79 | + $app->db->datalogInsert($record['dbtable'], $new_record, $dbidx[0]); |
61 | 80 |
|
62 | | - $app->tpl->setVar('success', true); |
63 | | -} else { |
64 | | - $app->tpl->setVar('success', false); |
| 81 | + $app->tpl->setVar('success', true); |
| 82 | + } |
65 | 83 | } |
66 | 84 |
|
67 | 85 | $app->tpl_defaults(); |
|
0 commit comments