Subversion Repositories eFlore/Applications.cel

Rev

Rev 1907 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1907 Rev 1932
Line 41... Line 41...
41
);
41
);
Line 42... Line 42...
42
 
42
 
43
 
43
 
-
 
44
function cel_get_obs() {
44
function cel_get_obs() {
45
	$URL = DOMAIN . '/jrest/InventoryObservationList/' . USER;
45
	$URL = DOMAIN . '/jrest/InventoryObservationList/' . USER;
46
	// 5000 (memory_limit)
Line 46... Line 47...
46
	return json_decode(file_get_contents($URL . '/?limite=100000&numero_page=0'));
47
	return json_decode(file_get_contents($URL . '/?limite=5000&numero_page=0'));
47
}
48
}
48
 
49
 
Line 57... Line 58...
57
 
58
 
58
	//set the url, number of POST vars, POST data
59
	//set the url, number of POST vars, POST data
59
	curl_setopt($ch,CURLOPT_URL, $URL . '/' . implode(',', $obs));
60
	curl_setopt($ch,CURLOPT_URL, $URL . '/' . implode(',', $obs));
60
	curl_setopt($ch,CURLOPT_POSTFIELDS, array('action' => 'DELETE'));
61
	curl_setopt($ch,CURLOPT_POSTFIELDS, array('action' => 'DELETE'));
-
 
62
	curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
-
 
63
 
61
	curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
64
	if(DEBUG) @fwrite(STDERR, sprintf("curl -F action=DELETE '%s/%s'\n", $URL, implode(',', $obs)));
62
	//execute post
65
	//execute post
63
	$result = curl_exec($ch);
66
	$result = curl_exec($ch);
64
	curl_close($ch);
67
	curl_close($ch);
65
	return $result;
68
	return $result;
Line 79... Line 82...
79
	return $result;
82
	return $result;
80
}
83
}
Line 81... Line 84...
81
 
84
 
82
 
85
 
83
function cel_delete_all_obs() {
86
function cel_delete_all_obs() {
-
 
87
    while( ($obs = cel_get_obs()) ) {
-
 
88
	$ordres = array_map(function($item) { return $item->ordre; }, $obs);
84
	$obs = cel_get_obs();
89
	// les chunks permettent d'éviter des REQUEST-URI too long (500 id * 4 digits + 500 (virgules)) < 4k
-
 
90
	while( $ordres_chunk = array_splice($ordres, 0, 500)) {
-
 
91
	    cel_delete_obs($ordres_chunk);
85
	$ordres = array_map(function($item) { return $item->ordre; }, $obs);
92
	}
Line 86... Line 93...
86
	cel_delete_obs($ordres);
93
    }
87
}
94
}