|
@@ -526,11 +526,11 @@ class REST_CRUD_API {
|
526
|
526
|
}
|
527
|
527
|
}
|
528
|
528
|
|
529
|
|
- protected function applyInputValidator($callback,$action,$database,$table,$input,$fields) {
|
|
529
|
+ protected function applyInputValidator($callback,$action,$database,$table,$input,$fields,$context) {
|
530
|
530
|
$errors = array();
|
531
|
531
|
if (is_callable($callback,true)) foreach ((array)$input as $key=>$value) {
|
532
|
532
|
if (isset($fields[$key])) {
|
533
|
|
- $error = $callback($action,$database,$table,$key,$fields[$key]->type,$value,$input);
|
|
533
|
+ $error = $callback($action,$database,$table,$key,$fields[$key]->type,$value,$context);
|
534
|
534
|
if ($error!==true) $errors[$key] = $error;
|
535
|
535
|
}
|
536
|
536
|
}
|
|
@@ -841,17 +841,17 @@ class REST_CRUD_API {
|
841
|
841
|
list($collect,$select) = $this->findRelations($table,$database,$db);
|
842
|
842
|
$columns = $this->findFields($table,$collect,$select,$columns,$database,$db);
|
843
|
843
|
|
844
|
|
- // input
|
845
|
|
- $input = $this->retrieveInput($post);
|
846
|
|
- if ($callbacks['input_sanitizer']) $this->applyInputSanitizer($callbacks['input_sanitizer'],$action,$database,$table[0],$input,$columns[$table[0]]);
|
847
|
|
- if ($callbacks['input_validator']) $this->applyInputValidator($callbacks['input_validator'],$action,$database,$table[0],$input,$columns[$table[0]]);
|
848
|
|
-
|
849
|
844
|
// permissions
|
850
|
845
|
if ($callbacks['table_authorizer']) $this->applyTableAuthorizer($callbacks['table_authorizer'],$action,$database,$table);
|
851
|
846
|
if ($callbacks['column_authorizer']) $this->applyColumnAuthorizer($callbacks['column_authorizer'],$action,$database,$columns);
|
852
|
847
|
|
853
|
|
- // limit removed columns
|
854
|
|
- if (!empty($input)) $input = $this->limitInputFields($input,$columns[$table[0]]);
|
|
848
|
+ // input
|
|
849
|
+ $context = $this->retrieveInput($post);
|
|
850
|
+ if (!empty($context)) $input = $this->limitInputFields($context,$columns[$table[0]]);
|
|
851
|
+
|
|
852
|
+ if ($callbacks['input_sanitizer']) $this->applyInputSanitizer($callbacks['input_sanitizer'],$action,$database,$table[0],$input,$columns[$table[0]]);
|
|
853
|
+ if ($callbacks['input_validator']) $this->applyInputValidator($callbacks['input_validator'],$action,$database,$table[0],$input,$columns[$table[0]],$context);
|
|
854
|
+
|
855
|
855
|
if (!empty($input)) $input = $this->convertBinary($input,$columns[$table[0]]);
|
856
|
856
|
|
857
|
857
|
return compact('action','database','table','key','callback','page','filters','satisfy','columns','order','transform','db','input','collect','select');
|