PHP7 compatibility

This commit is contained in:
Laurent Destailleur 2017-05-22 10:40:24 +02:00
parent f72ac3cf45
commit 8301e24261
3 changed files with 29 additions and 15 deletions

View File

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

View File

@ -36,8 +36,7 @@ class Documents extends DolibarrApi
* @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object * @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object
*/ */
static $DOCUMENT_FIELDS = array( static $DOCUMENT_FIELDS = array(
'modulepart', 'modulepart'
'filename'
); );
/** /**
@ -49,23 +48,36 @@ class Documents extends DolibarrApi
$this->db = $db; $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 * @throws RestException
*/ */
public function get($module_part, $filename) { public function index($module_part, $ref='', $subdir='') {
return array('note'=>'FeatureNotYetAvailable'); 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. * Push a file.
* Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. * Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.

View File

@ -98,7 +98,8 @@ class BankAccounts extends DolibarrApi
if ($result) { if ($result) {
$num = $this->db->num_rows($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); $obj = $this->db->fetch_object($result);
$account = new Account($this->db); $account = new Account($this->db);
if ($account->fetch($obj->rowid) > 0) { if ($account->fetch($obj->rowid) > 0) {