Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1934 → Rev 1935

/trunk/jrest/tests/cmd-test.php
8,7 → 8,9
if(isset($options['h']) || isset($options['help'])) die(__help());
 
 
define('USER', isset($options['u']) ? $options['u'] : (isset($options['user']) ? $options['user'] : DEFAULT_USER));
if(isset($options['u'])) define('USER', $options['u']);
elseif(isset($options['user'])) define('USER', $options['user']);
 
define('DOMAIN', isset($options['d']) ? $options['d'] : (isset($options['domain']) ? $options['domain'] : DEFAULT_DOMAIN));
define('EMAIL', isset($options['e']) ? $options['e'] : (isset($options['email']) ? $options['email'] : NULL));
define('PASS', isset($options['p']) ? $options['p'] : (isset($options['pass']) ? $options['pass'] : NULL));
20,6 → 22,10
// API::auth() define()'s COOKIE
require_once('api.php');
 
if(!defined('USER')) auth();
if(!defined('USER')) define('USER', DEFAULT_USER);
 
 
if(isset($options['o']) || isset($options['obs']) || isset($options['F']) || isset($options['flush'])) {
cel_delete_all_obs();
}
/trunk/jrest/tests/api.php
40,20 → 40,21
'observateur' => 'Observateur',
);
 
define('URLPREFIX', 'service:cel:');
 
function cel_get_obs() {
$URL = DOMAIN . '/jrest/InventoryObservationList/' . USER;
$URL = DOMAIN . '/' . URLPREFIX . 'InventoryObservationList/' . USER;
// 5000 (memory_limit)
return json_decode(file_get_contents($URL . '/?limite=5000&numero_page=0'));
}
 
function cel_get_images() {
$URL = DOMAIN . '/jrest/InventoryImageList/' . USER;
$URL = DOMAIN . '/' . URLPREFIX . 'InventoryImageList/' . USER;
return json_decode(file_get_contents($URL . '/?limite=100000&numero_page=0'));
}
 
function cel_delete_obs($obs) {
$URL = DOMAIN . '/jrest/InventoryObservationList/' . USER;
$URL = DOMAIN . '/' . URLPREFIX . 'InventoryObservationList/' . USER;
$ch = curl_init();
 
//set the url, number of POST vars, POST data
69,7 → 70,7
}
 
function cel_delete_image($img) {
$URL = DOMAIN . '/jrest/InventoryImageList/' . USER;
$URL = DOMAIN . '/' . URLPREFIX . 'InventoryImageList/' . USER;
$ch = curl_init();
 
//set the url, number of POST vars, POST data
102,7 → 103,7
 
function cel_upload_image($file) {
if(! file_exists($file)) return NULL;
$URL = DOMAIN . '/jrest/InventoryImage';
$URL = DOMAIN . '/' . URLPREFIX . 'InventoryImage';
 
$ch = curl_init();
 
123,7 → 124,7
}
 
function cel_link_images($user, $id_image, $id_obs) {
$URL = DOMAIN . '/jrest/inventoryImageLink/';
$URL = DOMAIN . '/' . URLPREFIX . 'inventoryImageLink/';
$ch = curl_init();
 
//set the url, number of POST vars, POST data
146,7 → 147,7
// TODO: CURLOPT_NETRC + Cel API support
if(!defined('EMAIL') || !defined('PASS') || ! EMAIL || ! PASS) return FALSE;
if(defined('COOKIE') && COOKIE) return TRUE;
$URL = DOMAIN . '/jrest/User/' . EMAIL . '/' . PASS;
$URL = DOMAIN . '/' . URLPREFIX . 'User/' . EMAIL . '/' . PASS;
 
$ch = curl_init();
 
191,7 → 192,7
}
 
function import($d) {
$URL = DOMAIN . '/jrest/ImportXLS';
$URL = DOMAIN . '/' . URLPREFIX . 'ImportXLS';
if(!is_file($d)) return FALSE;
$ch = curl_init();
 
215,7 → 216,7
}
 
function importXLS($d) {
$URL = DOMAIN . '/jrest/ImportXLS';
$URL = DOMAIN . '/' . URLPREFIX . 'ImportXLS';
if(!is_file($d)) return FALSE;
exec("csvtool -o /tmp/a.csv col 1- $d");
exec(__DIR__ . "/bin/csv2xls -v 0 -f -o /tmp/a /tmp/a.csv &>/dev/null");
249,7 → 250,7
function export($cols = "standard,avance") {
if(!defined('COOKIE')) return FALSE;
 
$URL = DOMAIN . '/jrest/CelWidgetExport/export?';
$URL = DOMAIN . '/' . URLPREFIX . 'CelWidgetExport/export?';
$URL .= http_build_query(array('colonnes' => $cols,
'id_utilisateur' => USER,
'format' => 'csv'));
272,7 → 273,7
 
$file = "/tmp/b.xls";
 
$URL = DOMAIN . '/jrest/CelWidgetExport/export?';
$URL = DOMAIN . '/' . URLPREFIX . 'CelWidgetExport/export?';
$URL .= http_build_query(array('colonnes' => $cols,
'id_utilisateur' => USER,
'format' => 'xls'));
328,6 → 329,7
 
 
function champsLongToShort($a) {
if(! $a) return array();
$r = array();
$x = array_flip($GLOBALS['champs']);
foreach($a as $k => $v) {