diff --git a/ChangeLog b/ChangeLog index e75d2eee5..0a484a2fc 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,13 @@ phpMyAdmin - Changelog $Id$ $Source$ +2003-12-04 Garvin Hicking + * browse_foreigner.php, mult_submits.inc.php, tbl_change.php, + tbl_replace.php, tbl_replace_fields.php, tbl_row_delete, + libraries/display_tbl.lib.php, libraries/display_tbl_links.lib.php: + Multi row edit via checkboxes in browse mode is now available. + This means, you can edit multiple records at once now. + 2003-12-02 Marc Delisle * libraries/display_tbl.lib.php: the constant used to check if the transformation function is included no longer exists diff --git a/browse_foreigners.php b/browse_foreigners.php index 677266c37..33252fa98 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -43,8 +43,8 @@ PMA_setFontSizes(); - - - - - - - - - -   - - - - - - - - - - - - 32000) { - echo ' ' . $strTextAreaLength . '' . "\n"; - } - } - else if ($type == 'enum') { - $enum = PMA_getEnumSetOptions($row_table_def['Type']); - $enum_cnt = count($enum); - ?> - - - - 20) { - echo "\n"; + // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one) + $m_rows = $o_rows + 1; + + for ($i = 0; $i < $fields_cnt; $i++) { + // Display the submit button after every 15 lines --swix + // (wanted to use an and instead, + // but it didn't worked because of the ) + + if ((($i % 15) == 0) && ($i != 0)) { ?> - + + +   + + ' . "\n"; - echo ' ' . "\n"; - } // end for - - } // end else echo "\n"; - ?> - - - - - - - - + + align="center" bgcolor=""> - // We don't want binary data destroyed - else if ($is_binary || $is_blob) { - if (($cfg['ProtectBinary'] && $is_blob) - || ($cfg['ProtectBinary'] == 'all' && $is_binary)) { + echo "\n"; + + // The type column + $is_binary = stristr($row_table_def['Type'], ' binary'); + $is_blob = stristr($row_table_def['Type'], 'blob'); + $is_char = stristr($row_table_def['Type'], 'char'); + switch ($row_table_def['True_Type']) { + case 'set': + $type = 'set'; + $type_nowrap = ''; + break; + case 'enum': + $type = 'enum'; + $type_nowrap = ''; + break; + case 'timestamp': + if (!$timestamp_seen) { // can only occur once per table + $timestamp_seen = 1; + $first_timestamp = 1; + } + $type = $row_table_def['Type']; + $type_nowrap = ' nowrap="nowrap"'; + break; + + default: + $type = $row_table_def['Type']; + $type_nowrap = ' nowrap="nowrap"'; + break; + } + ?> + > + + + '; + } else { + // loic1: display default values + if (!isset($row_table_def['Default'])) { + $row_table_def['Default'] = ''; + $real_null_value = TRUE; + $data = ''; + //$data = 'NULL'; + } else { + $data = $row_table_def['Default']; + } + $special_chars = htmlspecialchars($row_table_def['Default']); + $backup_field = ''; + } + + // The function column + // ------------------- + // Change by Bernard M. Piller + // We don't want binary data to be destroyed + // Note: from the MySQL manual: "BINARY doesn't affect how the column is + // stored or retrieved" so it does not mean that the contents is + // binary + if ($cfg['ShowFunctionFields']) { + if (($cfg['ProtectBinary'] && $is_blob) + || ($cfg['ProtectBinary'] == 'all' && $is_binary)) { + echo ' ' . $strBinary . '' . "\n"; + } else if (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) { + echo ' --' . "\n"; + } else { + ?> + + + + ' . "\n"; + if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary)) + && $row_table_def['Null'] == 'YES') { + echo ' 20) { + $onclick .= '1, '; + } else { + $onclick .= '2, '; + } + } else if (strstr($row_table_def['True_Type'], 'set')) { + $onclick .= '3, '; + } else if ($foreigners && isset($foreigners[$field])) { + $onclick .= '4, '; + } else { + $onclick .= '5, '; + } + $onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\'); this.checked = true}; return true" />' . "\n"; + echo $onclick; + } else { + echo '  ' . "\n"; + } + echo ' ' . "\n"; + + // The value column (depends on type) + // ---------------- + + require('./libraries/get_foreign.lib.php'); + + if (isset($foreign_link) && $foreign_link == true) { + ?> + + + + + ="return unNullify('')" tabindex="" id="field__3" value="" /> + + + + + + + + + + +   + + + + + + + + + + + + 32000) { + echo ' ' . $strTextAreaLength . '' . "\n"; + } + } + else if ($type == 'enum') { + $enum = PMA_getEnumSetOptions($row_table_def['Type']); + $enum_cnt = count($enum); + ?> + + + + 20) { + echo "\n"; + ?> + + ' . "\n"; + echo ' ' . "\n"; + } // end for + + } // end else echo "\n"; ?> - + + + + + + + + + // We don't want binary data destroyed + else if ($is_binary || $is_blob) { + if (($cfg['ProtectBinary'] && $is_blob) + || ($cfg['ProtectBinary'] == 'all' && $is_binary)) { + echo "\n"; + ?> + + + + + + + + + 40) ? 40 : $len); + $maxlength = $len; } echo "\n"; - ?> - - - - - - - + + + ="return unNullify('')" tabindex="" id="field__3" /> + '; + } + + if (!empty($cfg['UploadDir'])) { + if (substr($cfg['UploadDir'], -1) != '/') { + $cfg['UploadDir'] .= '/'; + } + if ($handle = @opendir($cfg['UploadDir'])) { + $is_first = 0; + while ($file = @readdir($handle)) { + if (is_file($cfg['UploadDir'] . $file) && !PMA_checkFileExtensions($file, '.sql')) { + if ($is_first == 0) { + echo "
\n"; + echo ' ' . $strOr . '' . ' ' . $strWebServerUploadDirectory . ' :
' . "\n"; + echo ' ' . "\n"; + } // end if (isfirst > 0) + @closedir($handle); + } else { + echo ' ' . $strError . '
' . "\n"; + echo ' ' . $strWebServerUploadDirectoryError . "\n"; + } + } // end if (web-server upload directory) + + echo ''; + + } // end else if ( binary or blob) + else { + // For char or varchar, respect the maximum length (M); for other + // types (int or float), the length is not a limit on the values that + // can be entered, so let's be generous (20) (we could also use the + // real limits for each numeric type) + if ($is_char) { $fieldsize = (($len > 40) ? 40 : $len); $maxlength = $len; } + else { + $fieldsize = $maxlength = 20; + } // end if... else... echo "\n"; ?> - - - ="return unNullify('')" tabindex="" id="field__3" /> + + '; - } - - if (!empty($cfg['UploadDir'])) { - if (substr($cfg['UploadDir'], -1) != '/') { - $cfg['UploadDir'] .= '/'; - } - if ($handle = @opendir($cfg['UploadDir'])) { - $is_first = 0; - while ($file = @readdir($handle)) { - if (is_file($cfg['UploadDir'] . $file) && !PMA_checkFileExtensions($file, '.sql')) { - if ($is_first == 0) { - echo "
\n"; - echo ' ' . $strOr . '' . ' ' . $strWebServerUploadDirectory . ' :
' . "\n"; - echo ' ' . "\n"; - } // end if (isfirst > 0) - @closedir($handle); + if ($is_char && isset($cfg['CharEditing']) && ($cfg['CharEditing'] == 'textarea')) { + echo "\n"; + ?> + + ' . $strError . '
' . "\n"; - echo ' ' . $strWebServerUploadDirectoryError . "\n"; + echo "\n"; + ?> + ="return unNullify('')" tabindex="" id="field__3" /> + '; - - } // end else if ( binary or blob) - else { - // For char or varchar, respect the maximum length (M); for other - // types (int or float), the length is not a limit on the values that - // can be entered, so let's be generous (20) (we could also use the - // real limits for each numeric type) - if ($is_char) { - $fieldsize = (($len > 40) ? 40 : $len); - $maxlength = $len; - } - else { - $fieldsize = $maxlength = 20; - } // end if... else... - echo "\n"; - ?> - - - - - - ="return unNullify('')" tabindex="" id="field__3" /> + - + - -
'; +} // end foreach on multi-edit ?> -
diff --git a/tbl_replace.php b/tbl_replace.php index 1e5286b8d..b9781aa8c 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -58,7 +58,7 @@ if (isset($err_url)) { $err_url = urldecode($err_url); } else { $err_url = str_replace('&', '&', $goto) - . (empty($primary_key) ? '' : '&primary_key=' . $primary_key); + . (empty($primary_key) ? '' : '&primary_key=' . (is_array($primary_key) ? $primary_key[0] : $primary_key)); } // Resets tables defined in the configuration file @@ -73,46 +73,60 @@ $seen_binary = FALSE; * Prepares the update of a row */ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) { - // Restore the "primary key" to a convenient format - $primary_key = urldecode($primary_key); - - // Defines the SET part of the sql query - $valuelist = ''; - - foreach($fields AS $key => $val) { - $encoded_key = $key; - $key = urldecode($key); - - require('./tbl_replace_fields.php'); - - // No change for this column and no MySQL function is used -> next column - if (empty($funcs[$encoded_key]) - && isset($fields_prev) && isset($fields_prev[$encoded_key]) - && ("'" . PMA_sqlAddslashes(urldecode($fields_prev[$encoded_key])) . "'" == $val)) { - continue; - } - else if (!empty($val)) { - if (empty($funcs[$encoded_key])) { - $valuelist .= PMA_backquote($key) . ' = ' . $val . ', '; - } else if ($val == '\'\'' - && (preg_match('@^(NOW|CURDATE|CURTIME|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$@', $funcs[$encoded_key]))) { - $valuelist .= PMA_backquote($key) . ' = ' . $funcs[$encoded_key] . '(), '; - } else { - $valuelist .= PMA_backquote($key) . ' = ' . $funcs[$encoded_key] . "($val), "; + $loop_array = (is_array($primary_key) ? $primary_key : array(0 => $primary_key)); + PMA_mysql_select_db($db); + $query = array(); + $message = ''; + + foreach($loop_array AS $primary_key_index => $enc_primary_key) { + // Restore the "primary key" to a convenient format + $primary_key = urldecode($enc_primary_key); + + // Defines the SET part of the sql query + $valuelist = ''; + + // Map multi-edit keys to single-level arrays, dependent on how we got the fields + $me_fields = (isset($fields['multi_edit']) ? $fields['multi_edit'][$enc_primary_key] : $fields); + $me_fields_prev = (isset($fields_prev['multi_edit']) ? $fields_prev['multi_edit'][$enc_primary_key] : $fields_prev); + $me_funcs = (isset($funcs['multi_edit']) ? $funcs['multi_edit'][$enc_primary_key] : $funcs); + $me_fields_type = (isset($fields_type['multi_edit']) ? $fields_type['multi_edit'][$enc_primary_key] : $fields_type); + $me_fields_null = (isset($fields_null['multi_edit']) ? $fields_null['multi_edit'][$enc_primary_key] : $fields_null); + + foreach($me_fields AS $key => $val) { + $encoded_key = $key; + $key = urldecode($key); + + require('./tbl_replace_fields.php'); + + // No change for this column and no MySQL function is used -> next column + if (empty($me_funcs[$encoded_key]) + && isset($me_fields_prev) && isset($me_fields_prev[$encoded_key]) + && ("'" . PMA_sqlAddslashes(urldecode($me_fields_prev[$encoded_key])) . "'" == $val)) { + continue; } + else if (!empty($val)) { + if (empty($me_funcs[$encoded_key])) { + $valuelist .= PMA_backquote($key) . ' = ' . $val . ', '; + } else if ($val == '\'\'' + && (preg_match('@^(NOW|CURDATE|CURTIME|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$@', $me_funcs[$encoded_key]))) { + $valuelist .= PMA_backquote($key) . ' = ' . $me_funcs[$encoded_key] . '(), '; + } else { + $valuelist .= PMA_backquote($key) . ' = ' . $me_funcs[$encoded_key] . "($val), "; + } + } + } // end while + + // Builds the sql update query + $valuelist = preg_replace('@, $@', '', $valuelist); + if (!empty($valuelist)) { + $query[] = 'UPDATE ' . PMA_backquote($table) . ' SET ' . $valuelist . ' WHERE' . $primary_key + . ' LIMIT 1'; + $message = $strAffectedRows . ' 
'; } - } // end while - - // Builds the sql update query - $valuelist = preg_replace('@, $@', '', $valuelist); - if (!empty($valuelist)) { - PMA_mysql_select_db($db); - $query = 'UPDATE ' . PMA_backquote($table) . ' SET ' . $valuelist . ' WHERE' . $primary_key - . ' LIMIT 1'; - $message = $strAffectedRows . ' '; } - // No change -> move back to the calling script - else { + + if (empty($valuelist)) { + // No change -> move back to the calling script $message = $strNoModification; if ($is_gotofile) { $js_to_run = 'functions.js'; @@ -130,41 +144,52 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) { * Prepares the insert of a row */ else { + $loop_array = (isset($primary_key) && is_array($primary_key) ? $primary_key : array(0 => (isset($primary_key) ? $primary_key : null))); + $query = array(); + $message = ''; PMA_mysql_select_db($db); + + foreach($loop_array AS $primary_key_index => $enc_primary_key) { + $fieldlist = ''; + $valuelist = ''; + + $me_fields = (isset($fields['multi_edit']) ? $fields['multi_edit'][$enc_primary_key] : $fields); + $me_fields_prev = (isset($fields_prev['multi_edit']) ? $fields_prev['multi_edit'][$enc_primary_key] : $fields_prev); + $me_funcs = (isset($funcs['multi_edit']) ? $funcs['multi_edit'][$enc_primary_key] : $funcs); + $me_fields_type = (isset($fields_type['multi_edit']) ? $fields_type['multi_edit'][$enc_primary_key] : $fields_type); + $me_fields_null = (isset($fields_null['multi_edit']) ? $fields_null['multi_edit'][$enc_primary_key] : $fields_null); - $fieldlist = ''; - $valuelist = ''; - - // garvin: Get, if sent, any protected fields to insert them here: - if (isset($fields_type) && is_array($fields_type) && isset($primary_key)) { - $prot_local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . urldecode($primary_key); - $prot_result = PMA_mysql_query($prot_local_query) or PMA_mysqlDie('', $prot_local_query, '', $err_url); - $prot_row = PMA_mysql_fetch_array($prot_result); - } - - foreach($fields AS $key => $val) { - $encoded_key = $key; - $key = urldecode($key); - $fieldlist .= PMA_backquote($key) . ', '; - - require('./tbl_replace_fields.php'); - - if (empty($funcs[$encoded_key])) { - $valuelist .= $val . ', '; - } else if (($val == '\'\'' - && preg_match('@^(UNIX_TIMESTAMP|RAND|LAST_INSERT_ID)$@', $funcs[$encoded_key])) - || preg_match('@^(NOW|CURDATE|CURTIME|USER)$@', $funcs[$encoded_key])) { - $valuelist .= $funcs[$encoded_key] . '(), '; - } else { - $valuelist .= $funcs[$encoded_key] . '(' . $val . '), '; + // garvin: Get, if sent, any protected fields to insert them here: + if (isset($me_fields_type) && is_array($me_fields_type) && isset($enc_primary_key)) { + $prot_local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . urldecode($enc_primary_key); + $prot_result = PMA_mysql_query($prot_local_query) or PMA_mysqlDie('', $prot_local_query, '', $err_url); + $prot_row = PMA_mysql_fetch_array($prot_result); } - } // end while - - // Builds the sql insert query - $fieldlist = preg_replace('@, $@', '', $fieldlist); - $valuelist = preg_replace('@, $@', '', $valuelist); - $query = 'INSERT INTO ' . PMA_backquote($table) . ' (' . $fieldlist . ') VALUES (' . $valuelist . ')'; - $message = $strInsertedRows . ' '; + + foreach($me_fields AS $key => $val) { + $encoded_key = $key; + $key = urldecode($key); + $fieldlist .= PMA_backquote($key) . ', '; + + require('./tbl_replace_fields.php'); + + if (empty($me_funcs[$encoded_key])) { + $valuelist .= $val . ', '; + } else if (($val == '\'\'' + && preg_match('@^(UNIX_TIMESTAMP|RAND|LAST_INSERT_ID)$@', $me_funcs[$encoded_key])) + || preg_match('@^(NOW|CURDATE|CURTIME|USER)$@', $me_funcs[$encoded_key])) { + $valuelist .= $me_funcs[$encoded_key] . '(), '; + } else { + $valuelist .= $me_funcs[$encoded_key] . '(' . $val . '), '; + } + } // end while + + // Builds the sql insert query + $fieldlist = preg_replace('@, $@', '', $fieldlist); + $valuelist = preg_replace('@, $@', '', $valuelist); + $query[] = 'INSERT INTO ' . PMA_backquote($table) . ' (' . $fieldlist . ') VALUES (' . $valuelist . ')'; + $message = $strInsertedRows . ' '; + } } // end row insertion @@ -172,41 +197,55 @@ else { * Executes the sql query and get the result, then move back to the calling * page */ -$sql_query = $query . ';'; -$result = PMA_mysql_query($query); -if (!$result) { - $error = PMA_mysql_error(); - require_once('./header.inc.php'); - PMA_mysqlDie($error, '', '', $err_url); -} else { - if (@mysql_affected_rows()) { - $message .= @mysql_affected_rows(); - } else { - $message = $strModifications; - } - $insert_id = mysql_insert_id(); - if ($insert_id != 0) { - $message .= '
'.$strInsertedRowId . ' ' . $insert_id; - } - if ($is_gotofile) { - if ($goto == 'db_details.php' && !empty($table)) { - unset($table); - } - $js_to_run = 'functions.js'; - $active_page = $goto; - require_once('./header.inc.php'); - require('./' . preg_replace('@\.\.*@', '.', $goto)); - } else { - // I don't understand this one: - //$add_query = (strpos(' ' . $goto, 'tbl_change') ? '&disp_query=' . urlencode($sql_query) : ''); +$sql_query = implode(';', $query) . ';'; +$total_affected_rows = 0; - // if we have seen binary, - // we do not append the query to the Location so it won't be displayed - // on the resulting page - // Nijel: we also need to limit size of url... - $add_query = (!$seen_binary && strlen($sql_query) < 1024 ? '&disp_query=' . urlencode($sql_query) : ''); - header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto . '&disp_message=' . urlencode($message) . $add_query); +foreach($query AS $query_index => $single_query) { + $result = PMA_mysql_query($single_query); + if (!$result) { + if ($cfg['IgnoreMultiSubmitErrors']) { + $message .= PMA_mysql_error(); + } else { + $error = PMA_mysql_error(); + require_once('./header.inc.php'); + PMA_mysqlDie($error, '', '', $err_url); + } + } else { + if (@mysql_affected_rows()) { + $total_affected_rows += @mysql_affected_rows; + } + + $insert_id = mysql_insert_id(); + if ($insert_id != 0) { + $message .= '
'.$strInsertedRowId . ' ' . $insert_id; + } + } // end if +} + +if ($total_affected_rows != 0) { + $message .= '
' . $total_affected_rows; +} else { + $message .= $strModifications; +} + +if ($is_gotofile) { + if ($goto == 'db_details.php' && !empty($table)) { + unset($table); } - exit(); -} // end if + $js_to_run = 'functions.js'; + $active_page = $goto; + require_once('./header.inc.php'); + require('./' . preg_replace('@\.\.*@', '.', $goto)); +} else { + // I don't understand this one: + //$add_query = (strpos(' ' . $goto, 'tbl_change') ? '&disp_query=' . urlencode($sql_query) : ''); + + // if we have seen binary, + // we do not append the query to the Location so it won't be displayed + // on the resulting page + // Nijel: we also need to limit size of url... + $add_query = (!$seen_binary && strlen($sql_query) < 1024 ? '&disp_query=' . urlencode($sql_query) : ''); + header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto . '&disp_message=' . urlencode($message) . $add_query); +} +exit(); ?> diff --git a/tbl_replace_fields.php b/tbl_replace_fields.php index b496bfc12..9dde6b349 100644 --- a/tbl_replace_fields.php +++ b/tbl_replace_fields.php @@ -26,13 +26,18 @@ PMA_checkParameters(array('db','encoded_key')); // binary file is uploaded, thus bypassing further manipulation of $val. $check_stop = false; -if (isset(${'fields_upload_' . $encoded_key}) && ${'fields_upload_' . $encoded_key} != 'none'){ + +// Check if a multi-edit row was found +${'me_fields_upload_' . $encoded_key} = (isset($enc_primary_key) && isset(${'fields_upload_' . $encoded_key}['multi_edit']) ? ${'fields_upload_' . $encoded_key}['multi_edit'][$enc_primary_key] : ${'fields_upload_' . $encoded_key}); +${'me_fields_uploadlocal_' . $encoded_key} = (isset($enc_primary_key) && isset(${'fields_uploadlocal_' . $encoded_key}['multi_edit']) ? ${'fields_uploadlocal_' . $encoded_key}['multi_edit'][$enc_primary_key] : ${'fields_uploadlocal_' . $encoded_key}); + +if (isset(${'me_fields_upload_' . $encoded_key}) && ${'me_fields_upload_' . $encoded_key} != 'none'){ // garvin: This fields content is a blob-file upload. - if (!empty(${'fields_upload_' . $encoded_key})) { + if (!empty(${'me_fields_upload_' . $encoded_key})) { // garvin: The blob-field is not empty. Check what we have there. - $data_file = ${'fields_upload_' . $encoded_key}; + $data_file = ${'me_fields_upload_' . $encoded_key}; if (is_uploaded_file($data_file)) { // garvin: A valid uploaded file is found. Look into the file... @@ -56,11 +61,11 @@ if (isset(${'fields_upload_' . $encoded_key}) && ${'fields_upload_' . $encoded_k // void } - } elseif (!empty(${'fields_uploadlocal_' . $encoded_key})) { + } elseif (!empty(${'me_fields_uploadlocal_' . $encoded_key})) { if (substr($cfg['UploadDir'], -1) != '/') { $cfg['UploadDir'] .= '/'; } - $file_to_upload = $cfg['UploadDir'] . preg_replace('@\.\.*@', '.', ${'fields_uploadlocal_' . $encoded_key}); + $file_to_upload = $cfg['UploadDir'] . preg_replace('@\.\.*@', '.', ${'me_fields_uploadlocal_' . $encoded_key}); // A local file will be uploaded. $open_basedir = @ini_get('open_basedir'); @@ -110,8 +115,18 @@ if (!$check_stop) { // f i e l d v a l u e i n t h e f o r m - if (isset($fields_type[$encoded_key])) $type = $fields_type[$encoded_key]; + if (isset($me_fields_type[$encoded_key])) $type = $me_fields_type[$encoded_key]; else $type = ''; + + $f = 'field_' . md5($key); + $t_fval = $$f; + + if (isset($t_fval['multi_edit'][$enc_primary_key])) { + $fval = &$t_fval['multi_edit'][$enc_primary_key]; + } else { + $fval = &$t_fval; + } + switch (strtolower($val)) { // let users type NULL or null to input this string and not a NULL value //case 'null': @@ -120,9 +135,8 @@ if (!$check_stop) { switch ($type) { case 'enum': // if we have an enum, then construct the value - $f = 'field_' . md5($key); - if (!empty($$f)) { - $val = implode(',', $$f); + if (!empty($fval)) { + $val = implode(',', $fval); if ($val == 'null') { // void } else { @@ -136,9 +150,8 @@ if (!$check_stop) { break; case 'set': // if we have a set, then construct the value - $f = 'field_' . md5($key); - if (!empty($$f)) { - $val = implode(',', $$f); + if (!empty($fval)) { + $val = implode(',', $fval); // the data here is not urlencoded! //$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'"; $val = "'" . PMA_sqlAddslashes($val) . "'"; @@ -148,9 +161,8 @@ if (!$check_stop) { break; case 'foreign': // if we have a foreign key, then construct the value - $f = 'field_' . md5($key); - if (!empty($$f)) { - $val = implode(',', $$f); + if (!empty($fval)) { + $val = implode(',', $fval); if ($val == 'null') { // void } else { @@ -196,7 +208,7 @@ if (!$check_stop) { // 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($fields_null) && isset($fields_null[$encoded_key]) + if (isset($me_fields_null) && isset($me_fields_null[$encoded_key]) && $val=="''") { $val = 'NULL'; } diff --git a/tbl_row_delete.php b/tbl_row_delete.php index 5c9db87ca..2073b3d6b 100644 --- a/tbl_row_delete.php +++ b/tbl_row_delete.php @@ -13,47 +13,75 @@ require_once('./header.inc.php'); // workaround for IE problem: if (isset($submit_mult_x)) { $submit_mult = 'row_delete'; +} elseif (isset($submit_mult_edit_x)) { + $submit_mult = 'row_edit'; } -if ((!empty($submit_mult) && isset($rows_to_delete) && is_array($rows_to_delete)) - || isset($mult_btn)) { - $action = 'tbl_row_delete.php'; - $err_url = 'tbl_row_delete.php?' . PMA_generate_common_url($db, $table); - if (!isset($mult_btn)) { - $original_sql_query = $sql_query; - $original_url_query = $url_query; - $original_pos = $pos; +// garvin: If the 'Ask for confirmation' button was pressed, this can only come from 'delete' mode, +// so we set it straight away. +if (isset($mult_btn)) { + $submit_mult = 'row_delete'; +} + +if (!empty($submit_mult)) { + switch($submit_mult) { + case 'row_edit': + if (isset($rows_to_delete) && is_array($rows_to_delete)) { + $primary_key = array(); + // garvin: As we got the fields to be edited from the 'rows_to_delete' checkbox, we use the index of it as the + // indicating primary key. Then we built the array which is used for the tbl_change.php script. + foreach($rows_to_delete AS $i_primary_key => $del_query) { + $primary_key[] = urldecode($i_primary_key); + } + + include './tbl_change.php'; + } + break; + + case 'row_delete': + default: + if ((isset($rows_to_delete) && is_array($rows_to_delete)) + || isset($mult_btn)) { + $action = 'tbl_row_delete.php'; + $err_url = 'tbl_row_delete.php?' . PMA_generate_common_url($db, $table); + if (!isset($mult_btn)) { + $original_sql_query = $sql_query; + $original_url_query = $url_query; + $original_pos = $pos; + } + require('./mult_submits.inc.php'); + } + $url_query = PMA_generate_common_url($db, $table) + . '&goto=tbl_properties.php'; + + + /** + * Show result of multi submit operation + */ + if ((!empty($submit_mult) && isset($rows_to_delete)) + || isset($mult_btn)) { + PMA_showMessage($strSuccess); + } + + if (isset($original_sql_query)) { + $sql_query = $original_sql_query; + } + + if (isset($original_url_query)) { + $url_query = $original_url_query; + } + + if (isset($original_pos)) { + $pos = $original_pos; + } + + require('./sql.php'); + + /** + * Displays the footer + */ + require_once('./footer.inc.php'); + break; } - require('./mult_submits.inc.php'); } -$url_query = PMA_generate_common_url($db, $table) - . '&goto=tbl_properties.php'; - - -/** - * Show result of multi submit operation - */ -if ((!empty($submit_mult) && isset($rows_to_delete)) - || isset($mult_btn)) { - PMA_showMessage($strSuccess); -} - -if (isset($original_sql_query)) { - $sql_query = $original_sql_query; -} - -if (isset($original_url_query)) { - $url_query = $original_url_query; -} - -if (isset($original_pos)) { - $pos = $original_pos; -} - -require('./sql.php'); - -/** - * Displays the footer - */ -require_once('./footer.inc.php'); ?>