diff --git a/include/class.attachment.php b/include/class.attachment.php index 5efa5ad6d78fca490c13b2fb2b33c5811d0c3cd7..6dd48233833d622186dd5f9395b15bce80ed523f 100644 --- a/include/class.attachment.php +++ b/include/class.attachment.php @@ -107,6 +107,7 @@ extends InstrumentedList { * additionally, add new files whose IDs are in the list provided. */ function keepOnlyFileIds($ids, $inline=false, $lang=false) { + if (!$ids) $ids = array(); $new = array_fill_keys($ids, 1); foreach ($this as $A) { if (!isset($new[$A->file_id]) && $A->lang == $lang && $A->inline == $inline) diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index d49186e7cab7a09b052584ac6e0bfeadb071b515..ff5ca11e338fa9597dcfb9a8ebe799e587e721ae 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -1210,13 +1210,11 @@ class DynamicFormEntry extends VerySimpleModel { $field = $a->getField(); if (!$field->hasData() || $field->isPresentationOnly()) continue; - $val = $v = $field->to_database($field->getClean()); - if (is_array($val)) - $v = $val[0]; - if ($a->value == $v) - continue; + $after = $field->to_database($field->getClean()); $before = $field->to_database($a->getValue()); - $fields[$field->get('id')] = array($before, $val); + if ($before == $after) + continue; + $fields[$field->get('id')] = array($before, $after); } return $fields; } diff --git a/include/class.forms.php b/include/class.forms.php index 1d3d822e29a6dff967a804c2b80fff12e5dfdbff..ecba6fa9f5af51f9d4249fa28e180e066e3ca8b0 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -2741,6 +2741,37 @@ class FileUploadField extends FormField { function asVarType() { return 'FileFieldAttachments'; } + + function whatChanged($before, $after) { + $B = (array) $before; + $A = (array) $after; + $added = array_diff($A, $B); + $deleted = array_diff($B, $A); + $added = Format::htmlchars(array_keys($added)); + $deleted = Format::htmlchars(array_keys($deleted)); + + if ($added && $deleted) { + $desc = sprintf( + __('added <strong>%1$s</strong> and removed <strong>%2$s</strong>'), + implode(', ', $added), implode(', ', $deleted)); + } + elseif ($added) { + $desc = sprintf( + __('added <strong>%1$s</strong>'), + implode(', ', $added)); + } + elseif ($deleted) { + $desc = sprintf( + __('removed <strong>%1$s</strong>'), + implode(', ', $deleted)); + } + else { + $desc = sprintf( + __('changed from <strong>%1$s</strong> to <strong>%2$s</strong>'), + $this->display($before), $this->display($after)); + } + return $desc; + } } class FileFieldAttachments { diff --git a/include/staff/ticket-edit.inc.php b/include/staff/ticket-edit.inc.php index 7d9140b455d68e8d5541d18f08f7506da856851c..e2bd902e24dc762bfb4bc8eee9b8eff338daf267 100644 --- a/include/staff/ticket-edit.inc.php +++ b/include/staff/ticket-edit.inc.php @@ -166,17 +166,24 @@ if ($_POST) <div class="body"></div> </div> <script type="text/javascript"> -$('table.dynamic-forms').sortable({ - items: 'tbody', - handle: 'th', - helper: function(e, ui) { - ui.children().each(function() { - $(this).children().each(function() { - $(this).width($(this).width()); - }); ++(function() { + var I = setInterval(function() { + if (!$.fn.sortable) + return; + clearInterval(I); + $('table.dynamic-forms').sortable({ + items: 'tbody', + handle: 'th', + helper: function(e, ui) { + ui.children().each(function() { + $(this).children().each(function() { + $(this).width($(this).width()); + }); + }); + ui=ui.clone().css({'background-color':'white', 'opacity':0.8}); + return ui; + } }); - ui=ui.clone().css({'background-color':'white', 'opacity':0.8}); - return ui; - } -}); + }, 20); +})(); </script> diff --git a/scp/js/tips.js b/scp/js/tips.js index 5801829bd10ec9f257dd47fb9030e8bdcf834393..ddf0051b651d2da3b186ec7ab8f01a5339064f4b 100644 --- a/scp/js/tips.js +++ b/scp/js/tips.js @@ -238,6 +238,8 @@ jQuery(function() { // Tooltip preview $(document).on('mouseover', '.preview', function(e) { var elem = $(this); + if (!elem.attr('href')) + return; var vars = elem.attr('href').split('='); if (!elem.data('preview')) return;