From 3a16bf9df08a8e38f67aafd16a2116114032066a Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 7 Aug 2008 23:25:58 +0200 Subject: [PATCH] [svn r15950] First cron task provided by Dokeos - Proof of concept - Loads a CSV file on disk and calls the webservice provided in /main/webservices/ to import users into Dokeos --- main/cron/user_import/client.php | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 main/cron/user_import/client.php diff --git a/main/cron/user_import/client.php b/main/cron/user_import/client.php new file mode 100644 index 0000000000..016c37a9db --- /dev/null +++ b/main/cron/user_import/client.php @@ -0,0 +1,35 @@ + + */ +/** + * This is a script used to automatically import a list of users from + * a CSV file into Dokeos. + * It is triggered by a cron task configured on the server + * @uses /main/webservices/user_import/ + * @author Eric Marguin + */ +/** + * Global cycle: init, execute, output + */ +require_once('../../inc/global.inc.php'); +// check if this client has been called by php_cli (command line or cron) +if(php_sapi_name()!='cli') +{ + echo 'You can\'t call this service throw a browser'; + die(); +} + +// include nusoap library +require_once(api_get_path(LIBRARY_PATH).'nusoap/nusoap.php'); + +// create client +$client = new nusoap_client(api_get_path(WEB_CODE_PATH).'cron/user_import/service.php'); + +// call import_user method +$response = $client->call('import_users', array('filepath' => api_get_path(SYS_CODE_PATH)."upload/users_import.csv", 'security_key'=>$_configuration['security_key'])); + +echo $response; +?>