Skip to content

Commit 2b515bd

Browse files
committed
Merge branch 'VyseExhale-patch-1'
2 parents 71116bc + 68a4043 commit 2b515bd

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

api.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,9 +1134,9 @@ protected function parseGetParameterArray($get,$name,$characters) {
11341134
return $values;
11351135
}
11361136

1137-
protected function applyBeforeHandler(&$action,&$database,&$table,&$id,&$callback,&$inputs) {
1137+
protected function applyBeforeHandler(&$action,&$database,&$table,&$id,&$callback,&$input) {
11381138
if (is_callable($callback,true)) {
1139-
$callback($action,$database,$table,$id,$inputs);
1139+
$callback($action,$database,$table,$id,$input);
11401140
}
11411141
}
11421142

@@ -1862,13 +1862,6 @@ protected function getParameters($settings) {
18621862
$page = $this->processPageParameter($page);
18631863
$orderings = $this->processOrderingsParameter($orderings);
18641864

1865-
// input
1866-
$multi = (strpos($key[0],',')!==false) || (strlen($post)?($post[0]=='['):false);
1867-
$inputs = $this->retrieveInputs($post);
1868-
if ($before) {
1869-
$this->applyBeforeHandler($action,$database,$tables[0],$key[0],$before,$inputs);
1870-
}
1871-
18721865
// reflection
18731866
list($tables,$collect,$select) = $this->findRelations($tables,$database,$auto_include);
18741867
$fields = $this->findFields($tables,$columns,$exclude,$select,$database);
@@ -1880,17 +1873,34 @@ protected function getParameters($settings) {
18801873
if ($tenancy_function) $this->applyTenancyFunction($tenancy_function,$action,$database,$fields,$filters);
18811874
if ($column_authorizer) $this->applyColumnAuthorizer($column_authorizer,$action,$database,$fields);
18821875

1876+
// input
1877+
$multi = (strpos($key[0],',')!==false) || (strlen($post)?($post[0]=='['):false);
1878+
if ($before && $action == 'delete' && $multi) {
1879+
$inputs = array();
1880+
for($i=1; $i <= count(explode(',', $key[0])); $i++) {
1881+
$inputs[] = (object) array();
1882+
}
1883+
} else {
1884+
$inputs = $this->retrieveInputs($post);
1885+
}
1886+
$originalAction = $action;
18831887
foreach ($inputs as $k=>$context) {
1888+
//echo $k.' - ';
18841889
$input = $this->filterInputByFields($context,$fields[$tables[0]]);
18851890

18861891
if ($tenancy_function) $this->applyInputTenancy($tenancy_function,$action,$database,$tables[0],$input,$fields[$tables[0]]);
18871892
if ($input_sanitizer) $this->applyInputSanitizer($input_sanitizer,$action,$database,$tables[0],$input,$fields[$tables[0]]);
18881893
if ($input_validator) $this->applyInputValidator($input_validator,$action,$database,$tables[0],$input,$fields[$tables[0]],$context);
18891894

1890-
$this->convertInputs($input,$fields[$tables[0]]);
1895+
$this->convertInputs($input,$fields[$tables[0]]);
1896+
1897+
if ($before) {
1898+
$action = $originalAction;
1899+
$this->applyBeforeHandler($action,$database,$tables[0],$ids[$k],$before,$input);
1900+
}
1901+
18911902
$inputs[$k] = $input;
18921903
}
1893-
18941904
return compact('action','database','tables','key','page','filters','fields','orderings','transform','multi','inputs','collect','select','before','after');
18951905
}
18961906

0 commit comments

Comments
 (0)