class Members extends DolibarrApi (View source)

API class for members

Properties

protected DoliDB $db from  DolibarrApi
Restler $r from  DolibarrApi
static string[] $FIELDS
AdherentStats $memberstats

Methods

__construct()

Constructor

string|array<string, mixed>
_checkValForAPI(string $field, string|string[] $value, object $object)

Check and convert a string depending on its type/name.

object
_filterObjectProperties(object $object, string $properties)

Filter properties that will be returned on object

object
_cleanObjectDatas(object $object)

Clean sensible object datas

static bool
_checkAccessToResource(string $resource, int $resource_id = 0, string $dbtablename = '', string $feature2 = '', string $dbt_keyfield = 'fk_soc', string $dbt_select = 'rowid')

Check access by user to a given resource

bool|string
_checkFilters(string $sqlfilters, string $error = '')

Return if a $sqlfilters parameter is valid Function no more used. Kept for backward compatibility with old APIs of modules

static string
_forge_criteria_callback(string[] $matches)

Function to forge a SQL criteria from a Generic filter string.

object
get(int $id)

Get properties of a member object

object
getByThirdparty(int $thirdparty)

Get properties of a member object by linked thirdparty

array|mixed
getByThirdpartyAccounts(string $site, string $key_account)

Get properties of a member object by linked thirdparty account

object
getByThirdpartyEmail(string $email)

Get properties of a member object by linked thirdparty email

object
getByThirdpartyBarcode(string $barcode)

Get properties of a member object by linked thirdparty barcode

array
index(string $sortfield = "t.rowid", string $sortorder = 'ASC', int $limit = 100, int $page = 0, string $typeid = '', int $category = 0, string $sqlfilters = '', string $properties = '', bool $pagination_data = false)

List members

int
post(array $request_data = null)

Create member object

object
put(int $id, array $request_data = null)

Update member

array
delete(int $id)

Delete member

array
getSubscriptions(int $id)

List subscriptions of a member

int
createSubscription(int $id, string $start_date, string $end_date, float $amount, string $label = '')

Add a subscription for a member

mixed
getCategories(int $id, string $sortfield = "s.rowid", string $sortorder = 'ASC', int $limit = 0, int $page = 0)

Get categories for a member

object
getType(int $id)

Get properties of a member type object

array
indexType(string $sortfield = "t.rowid", string $sortorder = 'ASC', int $limit = 100, int $page = 0, string $sqlfilters = '', string $properties = '', bool $pagination_data = false)

List members types

int
postType(array $request_data = null)

Create member type object

object
putType(int $id, array $request_data = null)

Update member type

array
deleteType(int $id)

Delete member type

array
getNbByMonth(int $year, int $format = 0)

Return an array with the number of members by month for a given year

array
getNbByYear()

Return an array with the number of subscriptions by year

array
getAmountByMonth(int $year, int $format = 0)

Return the number of subscriptions by month for a given year

array
getLastModifiedMembers(int $max)

Last Modified Members

Details

__construct()

Constructor

protected string|array<string, mixed> _checkValForAPI(string $field, string|string[] $value, object $object)

Check and convert a string depending on its type/name.

Parameters

string $field

Field name

string|string[] $value

Value to check/clean

object $object Object

Return Value

string|array<string, mixed>

Value cleaned

protected object _filterObjectProperties(object $object, string $properties)

Filter properties that will be returned on object

Parameters

object $object

Object to clean

string $properties

Comma separated list of properties names

Return Value

object

Object with cleaned properties

object _cleanObjectDatas(object $object)

Clean sensible object datas

Parameters

object $object

Object to clean

Return Value

object

Object with cleaned properties

static protected bool _checkAccessToResource(string $resource, int $resource_id = 0, string $dbtablename = '', string $feature2 = '', string $dbt_keyfield = 'fk_soc', string $dbt_select = 'rowid')

Check access by user to a given resource

Parameters

string $resource

element to check

int $resource_id

Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).

string $dbtablename

'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity. Not used if objectid is null (optional)

string $feature2

Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.

string $dbt_keyfield

Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)

string $dbt_select

Field name for select if not rowid. Not used if objectid is null (optional)

Return Value

bool

protected bool|string _checkFilters(string $sqlfilters, string $error = '')

Return if a $sqlfilters parameter is valid Function no more used. Kept for backward compatibility with old APIs of modules

Parameters

string $sqlfilters

sqlfilter string

string $error

Error message

Return Value

bool|string

True if valid, False if not valid

static protected string _forge_criteria_callback(string[] $matches)

Function to forge a SQL criteria from a Generic filter string.

Function no more used. Kept for backward compatibility with old APIs of modules

Parameters

string[] $matches

Array of found string by regex search. Each entry is 1 and only 1 criteria. Example: "t.ref:like:'SO-%'", "t.date_creation:<:'20160101'", "t.date_creation:<:'2016-01-01 12:30:00'", "t.nature:is:NULL", "t.field2:isnot:NULL"

Return Value

string

Forged criteria. Example: "t.field like 'abc%'"

object get(int $id)

Get properties of a member object

Return an array with member information

Parameters

int $id

ID of member

Return Value

object

Object with cleaned properties

Exceptions

RestException
RestException

object getByThirdparty(int $thirdparty)

Get properties of a member object by linked thirdparty

Return an array with member information

Parameters

int $thirdparty

ID of third party

Return Value

object

Data without useless information

Exceptions

RestException
RestException

array|mixed getByThirdpartyAccounts(string $site, string $key_account)

Get properties of a member object by linked thirdparty account

Parameters

string $site

Site key

string $key_account

Key of account

Return Value

array|mixed

Exceptions

RestException
RestException

object getByThirdpartyEmail(string $email)

Get properties of a member object by linked thirdparty email

Return an array with member information

Parameters

string $email

Email of third party

Return Value

object

Data without useless information

Exceptions

RestException
RestException

object getByThirdpartyBarcode(string $barcode)

Get properties of a member object by linked thirdparty barcode

Return an array with member information

Parameters

string $barcode

Barcode of third party

Return Value

object

Data without useless information

Exceptions

RestException
RestException

array index(string $sortfield = "t.rowid", string $sortorder = 'ASC', int $limit = 100, int $page = 0, string $typeid = '', int $category = 0, string $sqlfilters = '', string $properties = '', bool $pagination_data = false)

List members

Get a list of members

Parameters

string $sortfield

Sort field

string $sortorder

Sort order

int $limit

Limit for list

int $page

Page number

string $typeid

ID of the type of member

int $category

Use this param to filter list by category

string $sqlfilters

Other criteria to filter answers separated by a comma. Example: "(t.ref:like:'SO-%') and ((t.date_creation:<:'20160101') or (t.nature:is:NULL))"

string $properties

Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names

bool $pagination_data

If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*

Return Value

array

Array of member objects

Exceptions

RestException
RestException
RestException
RestException

int post(array $request_data = null)

Create member object

Parameters

array $request_data

Request data

Return Value

int

ID of member

Exceptions

RestException
RestException

object put(int $id, array $request_data = null)

Update member

Parameters

int $id

ID of member to update

array $request_data Datas

Return Value

object

Updated object

Exceptions

RestException
RestException
RestException

array delete(int $id)

Delete member

Parameters

int $id

member ID

Return Value

array

Exceptions

RestException
RestException
RestException

array getSubscriptions(int $id)

List subscriptions of a member

Get a list of subscriptions

Parameters

int $id

ID of member

Return Value

array

Array of subscription objects

Exceptions

RestException
RestException

int createSubscription(int $id, string $start_date, string $end_date, float $amount, string $label = '')

Add a subscription for a member

Parameters

int $id

ID of member

string $start_date

Start date {@from body} {@type timestamp}

string $end_date

End date {@from body} {@type timestamp}

float $amount

Amount (may be 0) {@from body}

string $label

Label {@from body}

Return Value

int

ID of subscription

Exceptions

RestException
RestException
RestException

mixed getCategories(int $id, string $sortfield = "s.rowid", string $sortorder = 'ASC', int $limit = 0, int $page = 0)

Get categories for a member

Parameters

int $id

ID of member

string $sortfield

Sort field

string $sortorder

Sort order

int $limit

Limit for list

int $page

Page number

Return Value

mixed

Exceptions

RestException
RestException
RestException

object getType(int $id)

Get properties of a member type object

Return an array with member type information

Parameters

int $id

ID of member type

Return Value

object

Object with cleaned properties

Exceptions

RestException
RestException

array indexType(string $sortfield = "t.rowid", string $sortorder = 'ASC', int $limit = 100, int $page = 0, string $sqlfilters = '', string $properties = '', bool $pagination_data = false)

List members types

Get a list of members types

Parameters

string $sortfield

Sort field

string $sortorder

Sort order

int $limit

Limit for list

int $page

Page number

string $sqlfilters

Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')"

string $properties

Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names

bool $pagination_data

If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*

Return Value

array

Array of member type objects

Exceptions

RestException
RestException
RestException

int postType(array $request_data = null)

Create member type object

Parameters

array $request_data

Request data

Return Value

int

ID of member type

Exceptions

RestException
RestException

object putType(int $id, array $request_data = null)

Update member type

Parameters

int $id

ID of member type to update

array $request_data Datas

Return Value

object

Updated object

Exceptions

RestException
RestException
RestException

array deleteType(int $id)

Delete member type

Parameters

int $id

member type ID

Return Value

array

Exceptions

RestException
RestException
RestException

array getNbByMonth(int $year, int $format = 0)

Return an array with the number of members by month for a given year

Parameters

int $year Year
int $format

0=Label of abscissa is a translated text 1=Label of abscissa is month number 2=Label of abscissa is first letter of month

Return Value

array

Array of statistics for last modified members

Exceptions

RestException

array getNbByYear()

Return an array with the number of subscriptions by year

Return Value

array

Array of statistics for last modified members

Exceptions

RestException

array getAmountByMonth(int $year, int $format = 0)

Return the number of subscriptions by month for a given year

Parameters

int $year Year
int $format

0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month

Return Value

array

Array of statistics for last modified members

Exceptions

RestException

array getLastModifiedMembers(int $max)

Last Modified Members

Get an array of statistics for last modified members

Parameters

int $max

Max numbers of members

Return Value

array

Array of statistics for last modified members

Exceptions

RestException