Browse Source

The temp dir for cache used by rester is correctly managed: No temp or
data files must be stored outside of documents directory.

Laurent Destailleur 9 years ago
parent
commit
73bcc3bfe3

+ 9 - 2
htdocs/api/class/api.class.php

@@ -17,6 +17,7 @@
 
 use Luracast\Restler\Restler;
 use Luracast\Restler\RestException;
+use Luracast\Restler\Defaults;
 
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
 
@@ -40,10 +41,16 @@ class DolibarrApi
     /**
      * Constructor
      *
-     * @param	DoliDb	$db		Database handler
+     * @param	DoliDb	$db		      Database handler
+     * @param   string  $cachedir     Cache dir
      */
-    function __construct($db) {
+    function __construct($db, $cachedir='')
+    {
         global $conf;
+        
+        if (empty($cachedir)) $cachedir = $conf->api->dir_temp;
+        Defaults::$cacheDirectory = $cachedir;
+        
         $this->db = $db;
         $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true );
         $this->r = new Restler($production_mode);

+ 2 - 2
htdocs/core/modules/modApi.class.php

@@ -57,7 +57,7 @@ class modApi extends DolibarrModules
 		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
 		$this->description = "REST interface";
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
-		$this->version = 'development';
+		$this->version = 'dolibarr';
 		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
 		// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
@@ -72,7 +72,7 @@ class modApi extends DolibarrModules
 
 		// Data directories to create when module is enabled.
 		// Example: this->dirs = array("/api/temp");
-		$this->dirs = array();
+		$this->dirs = array('/api/temp');
 
 		// Config pages. Put here list of php page, stored into api/admin directory, to use to setup module.
 		$this->config_page_url = array("index.php@api");

+ 1 - 1
htdocs/langs/en_US/admin.lang

@@ -1596,7 +1596,7 @@ EndPointIs=SOAP clients must send their requests to the Dolibarr endpoint availa
 ApiSetup=API module setup
 ApiDesc=By enabling this module, Dolibarr become a REST server to provide miscellaneous web services.
 KeyForApiAccess=Key to use API (parameter "api_key")
-ApiProductionMode=Enable production mode
+ApiProductionMode=Enable production mode (this will activate use of a caches for services management)
 ApiEndPointIs=You can access to the API at url
 ApiExporerIs=You can explore the API at url
 OnlyActiveElementsAreExposed=Only elements from enabled modules are exposed