' is checked.
*/
- var is_null = $this_field.data('value') == null;
+ var is_null = $this_field.data('value') === null;
fields_name.push(field_name);
- fields.push($this_field.data('value'));
- if (!is_null) {
+ if (is_null) {
+ fields_null.push('on');
+ fields.push('');
+ } else {
+ fields_null.push('');
+ fields.push($this_field.data('value'));
this_field_params[field_name] = $this_field.data('value');
var cell_index = $this_field.index('.to_be_saved');
@@ -932,23 +941,22 @@
relation_fields[cell_index] = {};
$.extend(relation_fields[cell_index], this_field_params);
}
- if (where_clause.indexOf(field_name) > -1) {
- new_clause += '`' + window.parent.table + '`.' + '`' + field_name + "` = '" + this_field_params[field_name].replace(/'/g,"''") + "'" + ' AND ';
+ if (where_clause.indexOf(PMA_urlencode(field_name)) > -1) {
+ var fields_str = PMA_urlencode('`' + g.table + '`.' + '`' + field_name + '` = ');
+ fields_str = fields_str.replace(/[+]/g, '[+]'); // replace '+' sign with '[+]' (regex)
+ var old_sub_clause_regex = new RegExp(fields_str + '[^+]*');
+ var new_sub_clause = PMA_urlencode('`' + g.table + '`.' + '`' + field_name + "` = '" + this_field_params[field_name].replace(/'/g,"''") + "'");
+ new_clause = new_clause.replace(old_sub_clause_regex, new_sub_clause);
}
}
- /*
- * update the where_clause, remove the last appended ' AND '
- * */
-
- // prepare and save new_clause
- new_clause = new_clause.substring(0, new_clause.length-5);
- new_clause = PMA_urlencode(new_clause);
+ // save new_clause
$this_field.parent('tr').data('new_clause', new_clause);
}); // end of loop for every edited cells in a row
me_fields_name.push(fields_name);
me_fields.push(fields);
+ me_fields_null.push(fields_null);
}); // end of loop for every edited rows
@@ -961,14 +969,15 @@
*/
var post_params = {'ajax_request' : true,
'sql_query' : full_sql_query,
- 'token' : window.parent.token,
- 'server' : window.parent.server,
- 'db' : window.parent.db,
- 'table' : window.parent.table,
+ 'token' : g.token,
+ 'server' : g.server,
+ 'db' : g.db,
+ 'table' : g.table,
'clause_is_unique' : nonunique,
'where_clause' : full_where_clause,
'fields[multi_edit]' : me_fields,
'fields_name[multi_edit]' : me_fields_name,
+ 'fields_null[multi_edit]' : me_fields_null,
'rel_fields_list' : rel_fields_list,
'do_transformations' : transformation_fields,
'transform_fields_list' : transform_fields_list,
@@ -978,12 +987,12 @@
};
if (!g.saveCellsAtOnce) {
- $(g.cEdit).find('*').attr('disabled', true);
+ $(g.cEdit).find('*').attr('disabled', 'disabled');
var $editArea = $(g.cEdit).find('.edit_area');
$editArea.addClass('edit_area_posting');
} else {
$('.save_edited').addClass('saving_edited_data')
- .attr('disabled', true);
+ .find('input').attr('disabled', 'disabled'); // disable the save button
}
$.ajax({
@@ -993,17 +1002,24 @@
success:
function(data) {
if (!g.saveCellsAtOnce) {
+ $(g.cEdit).find('*').removeAttr('disabled');
$editArea.removeClass('edit_area_posting');
} else {
$('.save_edited').removeClass('saving_edited_data')
- .attr('disabled', false);
+ .find('input').removeAttr('disabled'); // enable the save button back
}
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$('.to_be_saved').each(function() {
var new_clause = $(this).parent('tr').data('new_clause');
if (new_clause != '') {
- $(this).parent('tr').find('.where_clause').attr('value', new_clause);
+ var $where_clause = $(this).parent('tr').find('.where_clause');
+ var old_clause = $where_clause.attr('value');
+ $where_clause.attr('value', new_clause);
+ // update Edit, Copy, and Delete links also
+ $(this).parent('tr').find('a').each(function() {
+ $(this).attr('href', $(this).attr('href').replace(old_clause, new_clause));
+ });
}
});
// remove possible previous feedback message
@@ -1188,6 +1204,13 @@
// initialize cell editing configuration
g.saveCellsAtOnce = $('#save_cells_at_once').val();
+ // assign common hidden inputs
+ var $common_hidden_inputs = $('.common_hidden_inputs');
+ g.token = $common_hidden_inputs.find('input[name=token]').val();
+ g.server = $common_hidden_inputs.find('input[name=server]').val();
+ g.db = $common_hidden_inputs.find('input[name=db]').val();
+ g.table = $common_hidden_inputs.find('input[name=table]').val();
+
// initialize column order
$col_order = $('#col_order');
if ($col_order.length > 0) {
@@ -1405,7 +1428,9 @@
g.postEditedCell();
});
$(window).bind('beforeunload', function(e) {
- return g.isCellEdited ? g.saveCellWarning : null;
+ if (g.isCellEdited) {
+ g.saveCellWarning;
+ }
});
// add table class
diff --git a/js/sql.js b/js/sql.js
index 90ee728095..521b8e37b8 100644
--- a/js/sql.js
+++ b/js/sql.js
@@ -20,7 +20,7 @@ function PMA_urldecode(str) {
}
function PMA_urlencode(str) {
- return encodeURIComponent(str.replace(/\%20/g, '+'));
+ return encodeURIComponent(str).replace(/\%20/g, '+');
}
/**
diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php
index 472fbebbd9..cfb7cc6e78 100644
--- a/libraries/display_tbl.lib.php
+++ b/libraries/display_tbl.lib.php
@@ -397,6 +397,13 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di
'; ?>
'; ?>
'; ?>
+ ';
+ echo PMA_generate_common_hidden_inputs($db, $table);
+ echo '';
+ ?>
|
diff --git a/libraries/tbl_replace_fields.inc.php b/libraries/tbl_replace_fields.inc.php
index 32da9c085d..f1a0b9ed02 100644
--- a/libraries/tbl_replace_fields.inc.php
+++ b/libraries/tbl_replace_fields.inc.php
@@ -95,7 +95,7 @@ if (false !== $possibly_uploaded_val) {
// Was the Null checkbox checked for this field?
// (if there is a value, we ignore the Null checkbox: this could
// be possible if Javascript is disabled in the browser)
- if (isset($me_fields_null[$key])
+ if (! empty($me_fields_null[$key])
&& ($val == "''" || $val == '')) {
$val = 'NULL';
}
diff --git a/tbl_replace.php b/tbl_replace.php
index 75d041d81d..08750e43d8 100644
--- a/tbl_replace.php
+++ b/tbl_replace.php
@@ -271,8 +271,8 @@ foreach ($loop_array as $rownumber => $where_clause) {
// avoid setting a field to NULL when it's already NULL
// (field had the null checkbox before the update
// field still has the null checkbox)
- if (!(! empty($me_fields_null_prev[$key])
- && isset($me_fields_null[$key]))) {
+ if (empty($me_fields_null_prev[$key])
+ || empty($me_fields_null[$key])) {
$query_values[] = PMA_backquote($me_fields_name[$key]) . ' = ' . $cur_value;
}
}
@@ -528,7 +528,7 @@ if ($GLOBALS['is_ajax_request'] == true) {
/**Get the total row count of the table*/
$extra_data['row_count'] = PMA_Table::countRecords($_REQUEST['db'],$_REQUEST['table']);
- $extra_data['sql_query'] = PMA_showMessage(NULL, $GLOBALS['display_query']);
+ $extra_data['sql_query'] = PMA_showMessage($message, $GLOBALS['display_query']);
PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
}
|