Browse Source

PHP7 compatibility

Laurent Destailleur 8 years ago
parent
commit
8301e24261

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

@@ -66,6 +66,7 @@ class DolibarrApi
      *
      * @return array
      */
+    /* Disabled, most APIs does not share same signature for method index 
     function index()
     {
         return array(
@@ -74,7 +75,7 @@ class DolibarrApi
                 'message' => __class__.' is up and running!'
             )
         );
-    }
+    }*/
 
 
     /**

+ 25 - 13
htdocs/api/class/api_documents.class.php

@@ -36,8 +36,7 @@ class Documents extends DolibarrApi
      * @var array   $DOCUMENT_FIELDS     Mandatory fields, checked when create and update object
      */
     static $DOCUMENT_FIELDS = array(
-        'modulepart',
-        'filename'
+        'modulepart'
     );
 
     /**
@@ -49,23 +48,36 @@ class Documents extends DolibarrApi
         $this->db = $db;
     }
 
-
+    
     /**
-     * Return a document
+     * Return list of documents.
+     *
+     * @param   string  $module_part    Name of module or area concerned by file download ('facture', ...)
+     * @param   string  $ref            Reference of object (This will define subdir automatically)
+     * @param   string  $subdir         Subdirectory (Only if ref not provided)
+     * @return  array                   List of documents
      *
-     * @param   string  $module_part    Module part for file
-     * @param   string  $filename       File name
-     * 
-     * @url	GET {module_part}/{filename}
-     * 
-     * @return  array                   Array with data of file
      * @throws RestException
      */
-    public function get($module_part, $filename) {
+    public function index($module_part, $ref='', $subdir='') {
         return array('note'=>'FeatureNotYetAvailable');
     }
-     
-     
+    
+    
+    /**
+     * Return a document.
+     *
+     * @param   int         $id          ID of document
+     * @return  array                    Array with data of file
+     *
+     * @throws RestException
+     */
+    /*
+    public function get($id) {
+        return array('note'=>'xxx');
+    }*/
+    
+    
     /**
      * Push a file. 
      * Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.

+ 2 - 1
htdocs/compta/bank/class/api_bankaccounts.class.php

@@ -98,7 +98,8 @@ class BankAccounts extends DolibarrApi
 
         if ($result) {
             $num = $this->db->num_rows($result);
-            for ($i = 0; $i < min($num, ($limit <= 0 ? $num : $limit)); $i++) {
+            $minnum = min($num, ($limit <= 0 ? $num : $limit));
+            for ($i = 0; $i < $minnum; $i++) {
                 $obj = $this->db->fetch_object($result);
                 $account = new Account($this->db);
                 if ($account->fetch($obj->rowid) > 0) {