Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c7604bb

Browse files
committed
can be done in a single place
1 parent 783477c commit c7604bb

2 files changed

Lines changed: 26 additions & 27 deletions

File tree

libraries/insert_edit.lib.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2398,6 +2398,25 @@ function PMA_getTableFields($db, $table)
23982398
*/
23992399
function PMA_determineInsertOrEdit($where_clause, $db, $table)
24002400
{
2401+
if (isset($_REQUEST['where_clause'])) {
2402+
$where_clause = $_REQUEST['where_clause'];
2403+
}
2404+
if (isset($_SESSION['edit_next'])) {
2405+
$where_clause = $_SESSION['edit_next'];
2406+
unset($_SESSION['edit_next']);
2407+
$after_insert = 'edit_next';
2408+
}
2409+
if (isset($_REQUEST['ShowFunctionFields'])) {
2410+
$GLOBALS['cfg']['ShowFunctionFields'] = $_REQUEST['ShowFunctionFields'];
2411+
}
2412+
if (isset($_REQUEST['ShowFieldTypesInDataEditView'])) {
2413+
$GLOBALS['cfg']['ShowFieldTypesInDataEditView'] =
2414+
$_REQUEST['ShowFieldTypesInDataEditView'];
2415+
}
2416+
if (isset($_REQUEST['after_insert'])) {
2417+
$after_insert = $_REQUEST['after_insert'];
2418+
}
2419+
24012420
if (isset($where_clause)) {
24022421
// we are editing
24032422
$insert_mode = false;
@@ -2425,7 +2444,8 @@ function PMA_determineInsertOrEdit($where_clause, $db, $table)
24252444

24262445
return array(
24272446
$insert_mode, $where_clause, $where_clause_array, $where_clauses,
2428-
$result, $rows, $found_unique_key
2447+
$result, $rows, $found_unique_key,
2448+
isset($after_insert) ? $after_insert : null
24292449
);
24302450
}
24312451

tbl_change.php

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,12 @@
2424
require_once 'libraries/insert_edit.lib.php';
2525

2626
/**
27-
* Sets global variables.
28-
* Here it's better to use a if, instead of the '?' operator
29-
* to avoid setting a variable to '' when it's not present in $_REQUEST
27+
* Determine whether Insert or Edit and set global variables
3028
*/
31-
32-
if (isset($_REQUEST['where_clause'])) {
33-
$where_clause = $_REQUEST['where_clause'];
34-
}
35-
if (isset($_SESSION['edit_next'])) {
36-
$where_clause = $_SESSION['edit_next'];
37-
unset($_SESSION['edit_next']);
38-
$after_insert = 'edit_next';
39-
}
40-
if (isset($_REQUEST['ShowFunctionFields'])) {
41-
$cfg['ShowFunctionFields'] = $_REQUEST['ShowFunctionFields'];
42-
}
43-
if (isset($_REQUEST['ShowFieldTypesInDataEditView'])) {
44-
$cfg['ShowFieldTypesInDataEditView'] = $_REQUEST['ShowFieldTypesInDataEditView'];
45-
}
46-
if (isset($_REQUEST['after_insert'])) {
47-
$after_insert = $_REQUEST['after_insert'];
48-
}
29+
list(
30+
$insert_mode, $where_clause, $where_clause_array, $where_clauses,
31+
$result, $rows, $found_unique_key, $after_insert
32+
) = PMA_determineInsertOrEdit($where_clause, $db, $table);
4933

5034

5135
/**
@@ -106,11 +90,6 @@
10690
$table_fields = PMA_getTableFields($db, $table);
10791

10892

109-
list(
110-
$insert_mode, $where_clause, $where_clause_array, $where_clauses,
111-
$result, $rows, $found_unique_key
112-
) = PMA_determineInsertOrEdit($where_clause, $db, $table);
113-
11493
// retrieve keys into foreign fields, if any
11594
$foreigners = PMA_getForeigners($db, $table);
11695

0 commit comments

Comments
 (0)