Fix PHPCS

This commit is contained in:
jfefe 2015-05-06 00:55:42 +02:00
parent 3b1f6e8a5a
commit dbb9449ee7
9 changed files with 187 additions and 155 deletions

View File

@ -19,7 +19,6 @@
/**
*
* API class for skeleton object
*
* @smart-auto-routing false
@ -28,10 +27,9 @@
*
*
*/
class SkeletonApi extends DolibarrApi {
class SkeletonApi extends DolibarrApi
{
/**
*
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
@ -61,10 +59,10 @@ class SkeletonApi extends DolibarrApi {
*
* Return an array with skeleton informations
*
* @url GET skeleton/{id}
* @param int $id ID of skeleton
* @return array|mixed data without useless information
*
* @url GET skeleton/{id}
* @throws RestException
*/
function get($id)
@ -89,8 +87,6 @@ class SkeletonApi extends DolibarrApi {
* List skeletons
*
* Get a list of skeletons
*
* @url GET /skeletons/
*
* @param int $mode Use this param to filter list
* @param string $sortfield Sort field
@ -99,6 +95,8 @@ class SkeletonApi extends DolibarrApi {
* @param int $page Page number
*
* @return array Array of skeleton objects
*
* @url GET /skeletons/
*/
function getList($mode, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf;
@ -177,9 +175,10 @@ class SkeletonApi extends DolibarrApi {
/**
* Create skeleton object
*
* @url POST skeleton/
* @param array $request_data
* @param array $request_data Request datas
* @return int ID of skeleton
*
* @url POST skeleton/
*/
function post($request_data = NULL)
{
@ -201,10 +200,11 @@ class SkeletonApi extends DolibarrApi {
/**
* Update skeleton
*
* @url PUT skeleton/{id}
* @param int $id Id of skeleton to update
* @param array $request_data Datas
* @return int
*
* @url PUT skeleton/{id}
*/
function put($id, $request_data = NULL)
{
@ -234,9 +234,10 @@ class SkeletonApi extends DolibarrApi {
/**
* Delete skeleton
*
* @param int $id Skeleton ID
* @return array
*
* @url DELETE skeleton/{id}
* @param int $id
* @return type
*/
function delete($id)
{
@ -268,8 +269,10 @@ class SkeletonApi extends DolibarrApi {
/**
* Validate fields before create or update object
* @param array $data
*
* @param array $data Data to validate
* @return array
*
* @throws RestException
*/
function _validate($data)

View File

@ -22,8 +22,10 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
/**
* Class for API
*
*/
class DolibarrApi {
class DolibarrApi
{
/**
* @var DoliDb $db Database object
@ -38,7 +40,7 @@ class DolibarrApi {
/**
* Constructor
*
* @var DoliDB $db Database handler
* @param DoliDb $db Database handler
*/
function __construct($db) {
$this->db = $db;
@ -49,6 +51,7 @@ class DolibarrApi {
* Executed method when API is called without parameter
*
* Display a short message an return a http code 200
*
* @return array
*/
function index()
@ -64,13 +67,14 @@ class DolibarrApi {
/**
* Clean sensible object datas
* @var object $object Object to clean
*
* @param object $object Object to clean
* @return array Array of cleaned object properties
*
* @todo use an array for properties to clean
*
*/
protected function _cleanObjectDatas($object){
function _cleanObjectDatas($object) {
// Remove $db object property for object
unset($object->db);
@ -130,10 +134,9 @@ class DolibarrApi {
* API init
*
*/
class DolibarrApiInit extends DolibarrApi {
class DolibarrApiInit extends DolibarrApi
{
function __construct() {
global $db;
$this->db = $db;
@ -143,11 +146,12 @@ class DolibarrApiInit extends DolibarrApi {
* Login
*
* Log user with username and password
* @todo : to finish!
*
* @param string $login Username
* @param string $password User password
* @param int $entity User entity
* @param string $login Username
* @param string $password User password
* @param int $entity User entity
* @return array Response status and user token
*
* @throws RestException
*/
public function login($login, $password, $entity = 0) {
@ -194,6 +198,8 @@ class DolibarrApiInit extends DolibarrApi {
}
/**
* Get status (Dolibarr version)
*
* @access protected
* @class DolibarrApiAccess {@requires admin}
*/
@ -205,6 +211,5 @@ class DolibarrApiInit extends DolibarrApi {
'dolibarr_version' => DOL_VERSION
)
);
}
}
}

View File

@ -7,7 +7,7 @@ use Luracast\Restler\RestException;
/**
* Description of DolibarrApiAccess
* Dolibarr API access class
*
* @author jfefe
*/
@ -97,6 +97,10 @@ class DolibarrApiAccess implements iAuthenticate
}
/**
* Verify access
*
* @param array $m Properties of method
*
* @access private
*/
public static function verifyAccess(array $m)

View File

@ -20,7 +20,6 @@
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
/**
*
* API class for category object
*
* @smart-auto-routing false
@ -29,10 +28,9 @@
*
*
*/
class CategoryApi extends DolibarrApi {
class CategoryApi extends DolibarrApi
{
/**
*
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
@ -72,11 +70,10 @@ class CategoryApi extends DolibarrApi {
*
* Return an array with category informations
*
* @url GET category/{id}
*
* @param int $id ID of category
* @return array|mixed data without useless information
*
* @url GET category/{id}
* @throws RestException
*/
function get($id)
@ -102,15 +99,14 @@ class CategoryApi extends DolibarrApi {
*
* Get a list of categories
*
* @url GET /category/list
*
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
*
* @return array Array of category objects
*
* @url GET /category/list
*/
function getList($type='product', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf;
@ -170,14 +166,13 @@ class CategoryApi extends DolibarrApi {
/**
* Get member categories list
*
* @url GET /category/list/member
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
*
* @return mixed
*
* @url GET /category/list/member
*/
function getListCategoryMember($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
return $this->getList('member', $sortfield, $sortorder, $limit, $page);
@ -186,14 +181,14 @@ class CategoryApi extends DolibarrApi {
/**
* Get customer categories list
*
* @url GET /category/list/customer
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
*
* @return mixed
*
* @url GET /category/list/customer
*/
function getListCategoryCustomer($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
return $this->getList('customer', $sortfield, $sortorder, $limit, $page);
@ -202,14 +197,14 @@ class CategoryApi extends DolibarrApi {
/**
* Get supplier categories list
*
* @url GET /category/list/supplier
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
*
* @return mixed
*
* @url GET /category/list/supplier
*/
function getListCategorySupplier($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
return $this->getList('supplier', $sortfield, $sortorder, $limit, $page);
@ -218,14 +213,14 @@ class CategoryApi extends DolibarrApi {
/**
* Get product categories list
*
* @url GET /category/list/product
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
*
* @return mixed
*
* @url GET /category/list/product
*/
function getListCategoryProduct($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
return $this->getList('product', $sortfield, $sortorder, $limit, $page);
@ -234,9 +229,13 @@ class CategoryApi extends DolibarrApi {
/**
* Get contact categories list
*
* @url GET /category/list/contact
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @return mixed
*
* @url GET /category/list/contact
*/
function getListCategoryContact($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
return $this->getList('contact', $sortfield, $sortorder, $limit, $page);
@ -244,10 +243,11 @@ class CategoryApi extends DolibarrApi {
/**
* Create category object
*
* @param array $request_data Request data
* @return int ID of category
*
* @url POST category/
* @param array $request_data
* @return int ID of category
*/
function post($request_data = NULL)
{
@ -268,11 +268,12 @@ class CategoryApi extends DolibarrApi {
/**
* Update category
*
* @url PUT category/{id}
*
* @param int $id Id of category to update
* @param array $request_data Datas
* @return int
*
* @url PUT category/{id}
*/
function put($id, $request_data = NULL)
{
@ -302,9 +303,10 @@ class CategoryApi extends DolibarrApi {
/**
* Delete category
*
* @param int $id Category ID
* @return array
*
* @url DELETE category/{id}
* @param int $id
* @return type
*/
function delete($id)
{
@ -334,8 +336,10 @@ class CategoryApi extends DolibarrApi {
/**
* Validate fields before create or update object
* @param array $data
*
* @param array $data Data to validate
* @return array
*
* @throws RestException
*/
function _validate($data)

View File

@ -20,19 +20,22 @@
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
/**
*
* API class for commande object
*
* @smart-auto-routing false
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*
* @category Api
* @package Api
* @author jfefe
*
*
*/
class CommandeApi extends DolibarrApi {
class CommandeApi extends DolibarrApi
{
/**
*
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
@ -61,14 +64,14 @@ class CommandeApi extends DolibarrApi {
* Get properties of a commande object
*
* Return an array with commande informations
*
* @url GET order/{id}
* @param int $id ID of order
* @param string $ref Ref of object
*
* @param int $id ID of order
* @param string $ref Ref of object
* @param string $ref_ext External reference of object
* @param string $ref_int Internal reference of other object
* @return array|mixed data without useless information
*
*
* @url GET order/{id}
* @throws RestException
*/
function get($id='',$ref='', $ref_ext='', $ref_int='')
@ -94,8 +97,6 @@ class CommandeApi extends DolibarrApi {
* List orders
*
* Get a list of orders
*
* @url GET /order/list
*
* @param int $mode Use this param to filter list
* @param string $sortfield Sort field
@ -103,7 +104,8 @@ class CommandeApi extends DolibarrApi {
* @param int $limit Limit for list
* @param int $page Page number
*
* @return array Array of order objects
* @url GET /order/list
* @return array Array of order objects
*/
function getList($mode=0, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf;
@ -181,9 +183,11 @@ class CommandeApi extends DolibarrApi {
/**
* Create order object
*
* @url POST order/
* @param array $request_data
* @return int ID of commande
* @param array $request_data Request datas
*
* @url POST order/
*
* @return int ID of commande
*/
function post($request_data = NULL)
{
@ -206,9 +210,11 @@ class CommandeApi extends DolibarrApi {
/**
* Update order
*
* @url PUT order/{id}
* @param int $id Id of commande to update
* @param array $request_data Datas
*
* @url PUT order/{id}
*
* @return int
*/
function put($id, $request_data = NULL)
@ -237,11 +243,13 @@ class CommandeApi extends DolibarrApi {
}
/**
* Delete commande
* Delete order
*
* @url DELETE order/{id}
* @param int $id
* @return type
* @param int $id Order ID
*
* @url DELETE order/{id}
*
* @return array
*/
function delete($id)
{
@ -273,11 +281,14 @@ class CommandeApi extends DolibarrApi {
/**
* Validate an order
*
* @param int $id Order ID
* @param int $idwarehouse Warehouse ID
*
* @url GET order/{id}/validate
* @url POST order/{id}/validate
*
* @param int $id Order ID
* @param int $warehouse Warehouse ID
* @return array
*
*/
function validOrder($id, $idwarehouse=0)
{
@ -307,9 +318,10 @@ class CommandeApi extends DolibarrApi {
/**
* Validate fields before create or update object
* @param array $data
* @return array
* @throws RestException
*
* @param array $data Array with data to verify
* @return array
* @throws RestException
*/
function _validate($data)
{

View File

@ -20,17 +20,15 @@
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
/**
*
* API class for invoice object
*
* @smart-auto-routing false
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*
*
*/
class InvoiceApi extends DolibarrApi {
class InvoiceApi extends DolibarrApi
{
/**
*
* @var array $FIELDS Mandatory fields, checked when create and update object
@ -61,11 +59,11 @@ class InvoiceApi extends DolibarrApi {
* Get properties of a invoice object
*
* Return an array with invoice informations
*
* @url GET invoice/{id}
*
* @param int $id ID of invoice
* @return array|mixed data without useless information
*
*
* @url GET invoice/{id}
* @throws RestException
*/
function get($id)
@ -90,11 +88,6 @@ class InvoiceApi extends DolibarrApi {
* List invoices
*
* Get a list of invoices
*
* @url GET invoice/list
* @url GET invoice/list/{mode}
* @url GET thirdparty/{socid}/invoice/list
* @url GET thirdparty/{socid}/invoice/list/{mode}
*
* @param int $socid Filter list with thirdparty ID
* @param string $mode Filter by invoice status : draft | unpaid | paid | cancelled
@ -104,6 +97,11 @@ class InvoiceApi extends DolibarrApi {
* @param int $page Page number
*
* @return array Array of invoice objects
*
* @url GET invoice/list
* @url GET invoice/list/{mode}
* @url GET thirdparty/{socid}/invoice/list
* @url GET thirdparty/{socid}/invoice/list/{mode}
*/
function getList($socid=0, $mode='', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf;
@ -182,12 +180,11 @@ class InvoiceApi extends DolibarrApi {
/**
* Create invoice object
*
* @param array $request_data Request datas
* @return int ID of invoice
*
* @url POST invoice/
*
* @param array $request_data
*
* @return int ID of invoice
*/
function post($request_data = NULL)
{
@ -212,10 +209,11 @@ class InvoiceApi extends DolibarrApi {
/**
* Update invoice
*
* @url PUT invoice/{id}
* @param int $id Id of invoice to update
* @param array $request_data Datas
* @return int
*
* @url PUT invoice/{id}
*/
function put($id, $request_data = NULL)
{
@ -245,9 +243,10 @@ class InvoiceApi extends DolibarrApi {
/**
* Delete invoice
*
* @url DELETE invoice/{id}
* @param int $id
* @param int $id Invoice ID
* @return type
*
* @url DELETE invoice/{id}
*/
function delete($id)
{
@ -279,8 +278,10 @@ class InvoiceApi extends DolibarrApi {
/**
* Validate fields before create or update object
* @param array $data
*
* @param array $data Datas to validate
* @return array
*
* @throws RestException
*/
function _validate($data)

View File

@ -20,19 +20,16 @@
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
/**
*
* API class for product object
*
* @smart-auto-routing false
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*
*
*/
class ProductApi extends DolibarrApi {
class ProductApi extends DolibarrApi
{
/**
*
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
@ -63,10 +60,12 @@ class ProductApi extends DolibarrApi {
*
* Return an array with product informations
*
* @url GET product/{id}
* @param int $id ID of product
* @param int $id ID of product
* @param string $ref Product ref
* @param string $ref_ext Product ref ext
* @return array|mixed data without useless information
*
* @url GET product/{id}
* @throws RestException
*/
function get($id='', $ref='', $ref_ext='')
@ -93,8 +92,6 @@ class ProductApi extends DolibarrApi {
* List products
*
* Get a list of products
*
* @url GET /product/list
*
* @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service)
* @param mixed $to_sell Filter products to sell (1) or not to sell (0)
@ -105,6 +102,8 @@ class ProductApi extends DolibarrApi {
* @param int $page Page number
*
* @return array Array of product objects
*
* @url GET /product/list
*/
function getList($mode=0, $to_sell='', $to_buy='', $sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf;
@ -169,11 +168,11 @@ class ProductApi extends DolibarrApi {
/**
* Create product object
*
* @param array $request_data Request data
* @return int ID of product
*
* @url POST product/
*
* @param array $request_data
* @return int ID of product
*/
function post($request_data = NULL)
{
@ -197,12 +196,12 @@ class ProductApi extends DolibarrApi {
/**
* Update product
*
* @url PUT product/{id}
*
* @param int $id Id of product to update
* @param array $request_data Datas
* @return int
*
* @url PUT product/{id}
*/
function put($id, $request_data = NULL)
{
@ -231,10 +230,11 @@ class ProductApi extends DolibarrApi {
/**
* Delete product
*
* @param int $id Product ID
* @return array
*
* @url DELETE product/{id}
* @param int $id
* @return type
*/
function delete($id)
{
@ -255,7 +255,8 @@ class ProductApi extends DolibarrApi {
/**
* Validate fields before create or update object
* @param array $data
*
* @param array $data Datas to validate
* @return array
* @throws RestException
*/

View File

@ -20,18 +20,15 @@ use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
/**
*
* API class for contact object
*
* @smart-auto-routing false
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*
*
*/
class ContactApi extends DolibarrApi
{
/**
*
* @var array $FIELDS Mandatory fields, checked when create and update object
@ -62,10 +59,10 @@ class ContactApi extends DolibarrApi
*
* Return an array with contact informations
*
* @url GET contact/{id}
* @param int $id ID of contact
* @return array|mixed data without useless information
*
* @url GET contact/{id}
* @throws RestException
*/
function get($id) {
@ -92,20 +89,19 @@ class ContactApi extends DolibarrApi
* List contacts
*
* Get a list of contacts
*
* @url GET /contact/list
* @url GET /contact/list/{socid}
* @url GET /thirdparty/{socid}/contacts
*
*
* @param int $socid ID of thirdparty to filter list
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @throws RestException
*
* @return array Array of contact objects
*
* @url GET /contact/list
* @url GET /contact/list/{socid}
* @url GET /thirdparty/{socid}/contacts
*
* @throws RestException
*/
function getList($socid = 0, $sortfield = "c.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf;
@ -192,9 +188,10 @@ class ContactApi extends DolibarrApi
/**
* Create contact object
*
* @param array $request_data Request datas
* @return int ID of contact
*
* @url POST contact/
* @param array $request_data
* @return int ID of contact
*/
function post($request_data = NULL) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
@ -214,10 +211,11 @@ class ContactApi extends DolibarrApi
/**
* Update contact
*
* @url PUT contact/{id}
* @param int $id Id of contact to update
* @param array $request_data Datas
* @return int
*
* @url PUT contact/{id}
*/
function put($id, $request_data = NULL) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
@ -250,9 +248,10 @@ class ContactApi extends DolibarrApi
/**
* Delete contact
*
* @param int $id Contact ID
* @return array
*
* @url DELETE contact/{id}
* @param int $id
* @return type
*/
function delete($id) {
if (!DolibarrApiAccess::$user->rights->contact->supprimer)
@ -275,8 +274,9 @@ class ContactApi extends DolibarrApi
/**
* Validate fields before create or update object
* @param array $data
* @return array
*
* @param array $data Data to validate
* @return array
* @throws RestException
*/
function _validate($data) {

View File

@ -19,17 +19,15 @@
/**
*
* API class for thirdparty object
*
* @smart-auto-routing false
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*
*
*/
class ThirdpartyApi extends DolibarrApi {
class ThirdpartyApi extends DolibarrApi
{
/**
*
* @var array $FIELDS Mandatory fields, checked when create and update object
@ -65,10 +63,10 @@ class ThirdpartyApi extends DolibarrApi {
*
* Return an array with thirdparty informations
*
* @url GET thirdparty/{id}
* @param int $id ID of thirdparty
* @return array|mixed data without useless information
*
* @url GET thirdparty/{id}
* @throws RestException
*/
function get($id)
@ -93,8 +91,6 @@ class ThirdpartyApi extends DolibarrApi {
* List thirdparties
*
* Get a list of thirdparties
*
* @url GET /thirdparty/list
*
* @param int $mode Set to 1 to show only customers
* Set to 2 to show only prospects
@ -103,9 +99,10 @@ class ThirdpartyApi extends DolibarrApi {
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
*
*
* @return array Array of thirdparty objects
*
* @url GET /thirdparty/list
*
*/
function getList($mode=0, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
global $db, $conf;
@ -183,9 +180,9 @@ class ThirdpartyApi extends DolibarrApi {
/**
* Show customers
*
* @url GET /thirdparty/list/customers
*
* @return array List of customers
*
* @url GET /thirdparty/list/customers
*/
function getListCustomers() {
return $this->getList(1);
@ -194,9 +191,9 @@ class ThirdpartyApi extends DolibarrApi {
/**
* Show prospects
*
* @url GET /thirdparty/list/prospects
*
* @return array List of prospects
*
* @url GET /thirdparty/list/prospects
*/
function getListProspects() {
return $this->getList('',1);
@ -205,9 +202,9 @@ class ThirdpartyApi extends DolibarrApi {
/**
* Show other
*
* @url GET /thirdparty/list/others
*
* @return array List of thirpdparties who are not customer neither prospect
*
* @url GET /thirdparty/list/others
*/
function getListOthers() {
return $this->getList('','',1);
@ -216,9 +213,10 @@ class ThirdpartyApi extends DolibarrApi {
/**
* Create thirdparty object
*
* @url POST thirdparty/
* @param array $request_data
* @param array $request_data Request datas
* @return int ID of thirdparty
*
* @url POST thirdparty/
*/
function post($request_data = NULL)
{
@ -237,10 +235,11 @@ class ThirdpartyApi extends DolibarrApi {
/**
* Update thirdparty
*
* @url PUT thirdparty/{id}
* @param int $id Id of thirdparty to update
* @param array $request_data Datas
* @return int
*
* @url PUT thirdparty/{id}
*/
function put($id, $request_data = NULL)
{
@ -270,9 +269,10 @@ class ThirdpartyApi extends DolibarrApi {
/**
* Delete thirdparty
*
* @url DELETE thirdparty/{id}
* @param int $id
* @param int $id Thirparty ID
* @return type
*
* @url DELETE thirdparty/{id}
*/
function delete($id)
{
@ -293,8 +293,10 @@ class ThirdpartyApi extends DolibarrApi {
/**
* Validate fields before create or update object
* @param array $data
*
* @param array $data Datas to validate
* @return array
*
* @throws RestException
*/
function _validate($data)