Commit 81cc2836 authored by Marius Burkard's avatar Marius Burkard

- backported MR !640

parent 7ddeb2a4
......@@ -295,7 +295,10 @@ class remoting {
return false;
}
$insert_id = $app->db->insertID();
if ( isset($params['_primary_id'] ))
$insert_id = $params['_primary_id'];
else
$insert_id = $app->db->insertID();
// set a few values for compatibility with tform actions, mostly used by plugins
$this->id = $insert_id;
......
......@@ -199,7 +199,14 @@ class remoting_lib extends tform_base {
function getSQL($record, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '', $dummy = '') {
global $app;
// early usage. make sure _primary_id is sanitized if present.
if ( isset($record['_primary_id']) && is_numeric($record['_primary_id'])) {
$_primary_id = intval($record['_primary_id']);
if ($_primary_id > 0)
$this->primary_id_override = $_primary_id;
}
if(!is_array($this->formDef)) $app->error("Form definition not found.");
$this->dataRecord = $record;
......
......@@ -104,6 +104,7 @@ class tform_base {
var $module;
var $primary_id;
var $diffrec = array();
var $primary_id_override = 0;
/**
* Loading of the table definition
......@@ -1253,12 +1254,18 @@ class tform_base {
$this->action = $action;
$this->primary_id = $primary_id;
$record = $this->encode($record, $tab, true);
$sql_insert_key = '';
$sql_insert_val = '';
$sql_update = '';
$record = $this->encode($record, $tab, true);
if(($this->primary_id_override > 0)) {
$sql_insert_key .= '`'.$this->formDef["db_table_idx"].'`, ';
$sql_insert_val .= $this->primary_id_override.", ";
$record['_primary_id'] = $this->primary_id_override;
}
if($api == true) $fields = &$this->formDef['fields'];
else $fields = &$this->formDef['tabs'][$tab]['fields'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment