17 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
40 function paintHistory(&$owner, &$o, &$ei, $keywords=NULL)
42 $write_access = $owner->writeAccess(
'');
45 $prefix = $owner->getPrefix();
47 $db =& $GLOBALS[
'SQ_SYSTEM']->db;
51 $sql =
'SELECT sq_rb_ast.sq_eff_from as efrom, sq_rb_ast.sq_eff_to as eto, sq_rb_ast.version, sq_ast.name as updated_username, sq_rb_ast.updated_userid as updated_userid
55 LEFT JOIN sq_ast ON sq_rb_ast.updated_userid = sq_ast.assetid
58 sq_rb_ast.assetid = (:assetid)
61 ORDER BY sq_rb_ast.sq_eff_from DESC
65 $assetid = $owner->id;
69 }
catch (Exception $e) {
70 throw new Exception(
'Failed to get asset history due to database error: '.$e->getMessage());
73 $o->openSection(translate(
'version_history'));
76 if (SQ_ROLLBACK_VIEW) {
77 ?><p
class=
"sq-backend-data"><b><i><?php echo translate(
'history_viewed_row', htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)); ?></i></b></p>
81 hidden_field($prefix.
'_rollback_version',
'0');
84 <table
class=
"sq-backend-table">
86 <td
class=
"sq-backend-table-header"><?php echo translate(
'version_duration'); ?></td>
87 <td
class=
"sq-backend-table-header"><?php echo translate(
'time_since_version'); ?></td>
88 <td
class=
"sq-backend-table-header" align=
"center"><?php echo translate(
'updated_user'); ?></td>
89 <td
class=
"sq-backend-table-header" align=
"center"><?php echo translate(
'version'); ?></td>
93 <td
class=
"sq-backend-table-header" align=
"center"><?php echo translate(
'view'); ?></td>
100 foreach ($result as $data) {
101 $from = $data[
'efrom'];
103 $updated_username = $data[
'updated_username'];
104 $updated_userid = $data[
'updated_userid'];
106 $class =
'sq-backend-table-cell';
107 $show_view_btn = TRUE;
108 if (SQ_ROLLBACK_VIEW) {
109 $rollback_from = strtotime($_SESSION[
'sq_rollback_view'][
'rollback_time']);
110 if ($rollback_from >= strtotime($from) && (empty($to) || strtotime($to) > $rollback_from)) {
112 $show_view_btn = FALSE;
117 $to = translate(
'present');
118 $ago = translate(
'most_recent');
119 $show_view_btn = FALSE;
121 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
122 $ago = easy_time_total(time() - strtotime($from), TRUE);
123 list($fd, $ft) = explode(
' ', $from);
124 list($td, $tt) = explode(
' ', $to);
128 $to = date(
'd/m/Y H:i:s', strtotime($to));
134 <td
class=
"<?php echo $class; ?>"><?php echo date(
'd/m/Y H:i:s', strtotime($from)); ?> - <?php echo $to; ?></td>
135 <td
class=
"<?php echo $class; ?>"><?php echo $ago; ?></td>
136 <td
class=
"<?php echo $class; ?>"><?php echo empty($updated_username) ? $updated_userid : $updated_username; ?></td>
137 <td
class=
"<?php echo $class; ?>" align=
"center"><?php echo $data[
'version']; ?></td>
142 <td
class=
"<?php echo $class; ?>" align=
"center">
144 if ($show_view_btn) {
145 echo submit_button($prefix.
'_rollback_mode', translate(
'view'),
'this.form.'.$prefix.
'_rollback_version.value = \''.$data[
'version'].
'\'');
180 function processHistory(&$owner, &$o, &$ei)
183 $prefix = $owner->getPrefix();
185 if (isset($_POST[$prefix.
'_rollback_mode']) && isset($_POST[$prefix.
'_rollback_version'])) {
186 $version = $_POST[$prefix.
'_rollback_version'];
187 $url = $_SERVER[
'PHP_SELF'].
'?SQ_ACTION=rollback_view_start&assetid='.$owner->id.
'&version='.$version;
188 $o->setRedirect($url,
'top');