Commit 6dfc6d26 authored by ispcomm's avatar ispcomm
Browse files

_primary_id enforcing added to $params

parent aee2da20
......@@ -333,6 +333,9 @@ class remoting {
return false;
}
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
......
......@@ -200,7 +200,12 @@ class remoting_lib extends tform_base {
global $app;
$this->primary_id_override = true;
// 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 = intval($record['_primary_id']);
}
if(!is_array($this->formDef)) $app->error("Form definition not found.");
$this->dataRecord = $record;
......
......@@ -104,7 +104,7 @@ class tform_base {
var $module;
var $primary_id;
var $diffrec = array();
var $primary_id_override = false;
var $primary_id_override = 0;
/**
* Loading of the table definition
......@@ -1263,20 +1263,21 @@ 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 = '';
if($api == true) $fields = &$this->formDef['fields'];
else $fields = &$this->formDef['tabs'][$tab]['fields'];
$record = $this->encode($record, $tab, true);
if($this->primary_id_override && isset($record['_primary_id'])) {
if(($this->primary_id_override > 0)) {
$sql_insert_key .= '`'.$this->formDef["db_table_idx"].'`, ';
$sql_insert_val .= intval($record['_primary_id']).", ";
$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'];
// go trough all fields of the tab
if(is_array($record)) {
foreach($fields as $key => $field) {
......
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