18 require_once SQ_SYSTEM_ROOT.
'/core/assets/system/tool/tool.inc';
19 require_once SQ_INCLUDE_PATH.
'/rollback_management.inc';
45 $this->
Tool($assetid);
62 $tool_info = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_code);
64 $o->openSection($tool_info[
'name']);
67 if (!$GLOBALS[
'SQ_SYSTEM']->userSystemAdmin() && !$GLOBALS[
'SQ_SYSTEM']->userRoot()) {
69 $o->note(
'Access denied to run this tool');
74 $o->openField(translate(
'tool_rollback_rb_status'));
80 hidden_field($type_code.
'_rollback_status_old', (SQ_CONF_ROLLBACK_ENABLED) ?
'1' :
'0');
81 combo_box($type_code.
'_rollback_status', $options, FALSE, (SQ_CONF_ROLLBACK_ENABLED) ?
'1' :
'0');
89 $o->openField(translate(
'tool_rollback_reset_all_rb_entries'));
91 '0' => translate(
'no'),
92 '1' => translate(
'yes'),
94 combo_box($type_code.
'_reset_rollback_entries', $options, FALSE,
'');
95 $o->note(
'<b>'.translate(
'tool_rollback_reset_all_note').
'</b>');
98 $o->openField(translate(
'tool_rollback_purge_rb_entries_before'));
99 text_box($type_code.
'_purge_rollback_entries_period_amount',
'', 4, 4);
109 combo_box($type_code.
'_purge_rollback_entries_period_timeframe', $options, FALSE,
'');
112 $o->openField(translate(
'tool_rollback_purge_file_versioning_entries_before'));
113 text_box($type_code.
'_purge_file_entries_period_amount',
'', 4, 4);
123 combo_box($type_code.
'_purge_file_entries_period_timeframe', $options, FALSE,
'');
126 $o->openField(translate(
'tool_delete_redundant_entries'));
131 combo_box($type_code.
'_delete_redundant_entries', $options, FALSE, 0, 0,
"onChange=\"Javascript: if (this.value == 1) { if(!confirm(js_translate('tool_delete_redundant_entries_confirm'))) { this.value = 0; } } \"");
132 $o->note(translate(
'tool_delete_redundant_entries_note'));
136 if (isset($_REQUEST[
'redirect_to_sys_maintenance'])) {
137 $redirect_to_system_maintenance = (int)$_REQUEST[
'redirect_to_sys_maintenance'];
138 if ($redirect_to_system_maintenance) {
139 hidden_field(
'redirect_to_sys_maintenance', $redirect_to_system_maintenance);
144 $o->openField(translate(
'note'));
145 $o->note(translate(
'tool_rollback_usage_note'));
167 if (!$GLOBALS[
'SQ_SYSTEM']->userSystemAdmin() && !$GLOBALS[
'SQ_SYSTEM']->userRoot()) {
175 if (isset($_REQUEST[
'redirect_to_sys_maintenance'])) {
176 $redirect_to_system_maintenance = (int)$_REQUEST[
'redirect_to_sys_maintenance'];
177 if ($redirect_to_system_maintenance) {
178 $redirect_url = sq_web_path(
'admin').
'/?SQ_BACKEND_PAGE=main&backend_section=sys_maintenance&expand=rollback';
190 $rollback_date = date(
'Y-m-d H:i:s');
194 $reset_rollback_entries = $_REQUEST[$type_code.
'_reset_rollback_entries'];
198 $purge_rb_period = (int) $_REQUEST[$type_code.
'_purge_rollback_entries_period_amount'];
199 $purge_fv_period = (
int) $_REQUEST[$type_code.
'_purge_file_entries_period_amount'];
201 $purge_rb_time_unit = $_REQUEST[$type_code.
'_purge_rollback_entries_period_timeframe'];
202 $purge_fv_time_unit = $_REQUEST[$type_code.
'_purge_file_entries_period_timeframe'];
204 if ($purge_rb_period > 0) {
205 $time_unit = $time_units[$purge_rb_time_unit];
206 if ($purge_rb_period > 1) $time_unit .=
's';
207 $purge_rb_date = date(
'Y-m-d H:i:s', strtotime(
'-'.$purge_rb_period.
' '.$time_unit));
210 if ($purge_fv_period > 0) {
211 $time_unit = $time_units[$purge_fv_time_unit];
212 if ($purge_fv_period > 1) $time_unit .=
's';
213 $purge_fv_date = date(
'Y-m-d H:i:s', strtotime(
'-'.$purge_fv_period.
' '.$time_unit));
216 $rollback_status = $_REQUEST[$type_code.
'_rollback_status'];
217 $enable_rollback = FALSE;
218 $disable_rollback = FALSE;
220 if ($rollback_status != $_REQUEST[$type_code.
'_rollback_status_old']) {
221 $enable_rollback = ($rollback_status ==
'1');
222 $disable_rollback = ($rollback_status ==
'0');
225 $reset_rollback = ($_REQUEST[$type_code.
'_reset_rollback_entries'] ==
'1');
226 $delete_redundant_entries = ($_REQUEST[$type_code.
'_delete_redundant_entries'] ==
'1');
228 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
230 'enable_rollback' => $enable_rollback,
231 'disable_rollback' => $disable_rollback,
232 'rollback_date' => $rollback_date,
233 'purge_fv_date' => $purge_fv_date,
234 'purge_rb_date' => $purge_rb_date,
235 'reset_rollback' => $reset_rollback,
236 'delete_redundant_entries' => $delete_redundant_entries,
237 'fail_on_error' => TRUE,
240 $hh->queueHipo(
'hipo_job_rollback_management', $vars, $redirect_url);
242 $url = $hh->runQueuedJobs();
243 if (!empty($url)) $o->setRedirect($url);