Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Helmo
ISPConfig 3
Commits
880e4c71
Commit
880e4c71
authored
Dec 14, 2018
by
Marius Burkard
Browse files
- added undelete to datalog history viewer
parent
f08ea8ff
Changes
6
Hide whitespace changes
Inline
Side-by-side
interface/lib/classes/db_mysql.inc.php
View file @
880e4c71
...
...
@@ -759,6 +759,9 @@ class db
$old_rec
=
array
();
$index_value
=
$this
->
insertID
();
if
(
!
$index_value
&&
isset
(
$insert_data
[
$index_field
]))
{
$index_value
=
$insert_data
[
$index_field
];
}
$new_rec
=
$this
->
queryOneRecord
(
"SELECT * FROM ?? WHERE ?? = ?"
,
$tablename
,
$index_field
,
$index_value
);
$this
->
datalogSave
(
$tablename
,
'INSERT'
,
$index_field
,
$index_value
,
$old_rec
,
$new_rec
);
...
...
interface/web/monitor/dataloghistory_undo.php
View file @
880e4c71
...
...
@@ -50,18 +50,36 @@ $dbidx = explode(':', $record['dbidx']);
$old_record
=
$app
->
db
->
queryOneRecord
(
'SELECT * FROM ?? WHERE ??=?'
,
$record
[
'dbtable'
],
$dbidx
[
0
],
$dbidx
[
1
]);
if
(
is_array
(
$old_record
))
{
if
(
!
$data
=
unserialize
(
stripslashes
(
$record
[
'data'
])))
{
$data
=
unserialize
(
$record
[
'data'
]);
if
(
$record
[
'action'
]
===
'u'
)
{
if
(
is_array
(
$old_record
))
{
if
(
!
$data
=
unserialize
(
stripslashes
(
$record
[
'data'
])))
{
$data
=
unserialize
(
$record
[
'data'
]);
}
$new_record
=
$data
[
'old'
];
$app
->
db
->
datalogUpdate
(
$record
[
'dbtable'
],
$new_record
,
$dbidx
[
0
],
$dbidx
[
1
]);
$app
->
tpl
->
setVar
(
'success'
,
true
);
}
else
{
$app
->
tpl
->
setVar
(
'success'
,
false
);
}
}
elseif
(
$record
[
'action'
]
===
'd'
)
{
if
(
is_array
(
$old_record
))
{
$app
->
tpl
->
setVar
(
'success'
,
false
);
$app
->
tpl
->
setVar
(
'error_txt'
,
$wb
[
'error_undelete_txt'
]);
}
else
{
if
(
!
$data
=
unserialize
(
stripslashes
(
$record
[
'data'
])))
{
$data
=
unserialize
(
$record
[
'data'
]);
}
$new_record
=
$data
[
'old'
];
$new_record
=
$data
[
'old'
];
/* TODO: maybe check some data, e. g. server_id -> server still there?, sys_groupid -> sys_group/sys_user still there? */
$app
->
db
->
datalog
Update
(
$record
[
'dbtable'
],
$new_record
,
$dbidx
[
0
]
,
$dbidx
[
1
]
);
$app
->
db
->
datalog
Insert
(
$record
[
'dbtable'
],
$new_record
,
$dbidx
[
0
]);
$app
->
tpl
->
setVar
(
'success'
,
true
);
}
else
{
$app
->
tpl
->
setVar
(
'success'
,
false
);
$app
->
tpl
->
setVar
(
'success'
,
true
);
}
}
$app
->
tpl_defaults
();
...
...
interface/web/monitor/dataloghistory_view.php
View file @
880e4c71
...
...
@@ -109,6 +109,7 @@ switch ($record['action']) {
}
$app
->
tpl
->
setVar
(
$out
);
$app
->
tpl
->
setVar
(
'can_undo'
,
(
$out
[
'action_char'
]
===
'u'
||
$out
[
'action_char'
]
===
'd'
));
$app
->
tpl_defaults
();
$app
->
tpl
->
pparse
();
...
...
interface/web/monitor/lib/lang/de_dataloghistory_undo.lng
View file @
880e4c71
...
...
@@ -2,5 +2,6 @@
$wb
[
'list_head_txt'
]
=
'Datalog-History-Eintrag'
;
$wb
[
'success_txt'
]
=
'Erfolgreich zurückgesetzt'
;
$wb
[
'error_txt'
]
=
'Fehler beim Zurücksetzen: Eintrag existiert nicht mehr'
;
$wb
[
'error_undelete_txt'
]
=
'Fehler beim Wiederherstellen: Eintrag mit dieser Id existiert bereits'
;
$wb
[
'btn_cancel_txt'
]
=
'Zurück'
;
?>
interface/web/monitor/lib/lang/en_dataloghistory_undo.lng
View file @
880e4c71
...
...
@@ -2,5 +2,6 @@
$wb
[
'list_head_txt'
]
=
'Data Log History Entry'
;
$wb
[
'success_txt'
]
=
'Undo successful'
;
$wb
[
'error_txt'
]
=
'Error during undo: Record does not exist anymore'
;
$wb
[
'error_undelete_txt'
]
=
'Error during undelete: Record with primary id already existing.'
;
$wb
[
'btn_cancel_txt'
]
=
'Back'
;
?>
interface/web/monitor/templates/dataloghistory_view.htm
View file @
880e4c71
...
...
@@ -116,7 +116,7 @@
<div
class=
"clear"
>
<div
class=
"right"
>
<tmpl_if
name=
'
action_char'
value=
'u
'
>
<tmpl_if
name=
'
can_undo
'
>
<a
class=
"btn btn-default formbutton-danger formbutton-narrow"
href=
"javascript: ISPConfig.confirm_action('monitor/dataloghistory_undo.php?id={tmpl_var name='id'}','{tmpl_var name='undo_confirmation_txt'}');"
>
{tmpl_var name='undo_txt'}
</a>
</tmpl_if>
<button
class=
"btn btn-default formbutton-default"
type=
"button"
value=
"{tmpl_var name='btn_cancel_txt'}"
data-load-content=
"monitor/dataloghistory_list.php"
>
{tmpl_var name='btn_cancel_txt'}
</button>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment