Commit ccb0f526 authored by Lionel VEST's avatar Lionel VEST
Browse files

Add default values if some parameters are missing

parent a114669a
......@@ -36,22 +36,22 @@ function datagrid_validation($connection,$input)
die(json_encode(array("code" => 400, "message" => "Le champ 'fields=>width' est invalide")));
foreach($input->body->advanced_search as $field)
if(!preg_match("/^[a-z0-9_@.]+$/",$field->field))
if(!preg_match("/^[a-z0-9_]+$/",$field->field))
die(json_encode(array("code" => 400, "message" => "'field' invalide")));
//else if($field->operator)
//die(json_encode(array("code" => 400, "message" => "'operator' invalide");
//else if($field->value)
//die(json_encode(array("code" => 400, "message" => "'value' invalide");
else if($field->next != 'AND' AND $field->next != 'OR')
else if(@$field->next AND ($field->next != 'AND' AND $field->next != 'OR'))
die(json_encode(array("code" => 400, "message" => "'next' invalide")));
//if ($input->body->global_search)
//die(json_encode(array("code" => 400, "message" => "'global_search' invalide")));
if (!preg_match("/^\d+$/",$input->body->results))
if ($input->body->results AND !preg_match("/^\d+$/",$input->body->results))
die(json_encode(array("code" => 400, "message" => "'results' invalide")));
if (!preg_match("/^\d+$/",$input->body->page))
if ($input->body->page AND !preg_match("/^\d+$/",$input->body->page))
die(json_encode(array("code" => 400, "message" => "'page' invalide")));
}
......@@ -120,8 +120,12 @@ function datagrid_query($input, $dblink, $connection)
if (isset($search->value))
{
$search->dblink = $input->body->fields[$search->field]->dblink;
$search->field = $input->body->fields[$search->field]->name;
if (is_numeric($search->field))
$search->field = $input->body->fields[$search->field]->name;
if (@!$search->next)
$search->nect = 'AND';
if (@$search->dblink == null)
{
......
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