dolibarr 24.0.0-beta
Mailings Class Reference
Inheritance diagram for Mailings:
Collaboration diagram for Mailings:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id)
 Get a mass mailing.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $fk_projects='', $sqlfilters='', $properties='', $pagination_data=false, $loadlinkedobjects=0)
 List mass mailings.
 
 indexTargets ($id, $sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $sqlfilters='', $properties='', $pagination_data=false)
 List mass mailing targets.
 
 clone ($id, $cloneContent=1, $cloneRecipients=1, $notrigger=0)
 Clone a mass mailing.
 
 post ($request_data=null)
 Create a mass mailing.
 
 put ($id, $request_data=null)
 Update a mass mailing general fields (won't change lines of mass mailing)
 
 delete ($id)
 Delete a mass mailing.
 
 updateTarget ($id, $targetid, $request_data=null)
 Update a mass mailing general fields (won't change lines of mass mailing)
 
 postTarget ($id, $request_data=null)
 Create a mass mailing.
 
 getTarget ($id, $targetid)
 Get a target in a mass mailing.
 
 deleteTarget ($id, $targetid)
 Delete a mass mailing general fields (won't change lines of mass mailing)
 
 deleteTargets ($id)
 Delete targets of a mass mailing.
 
 resetTargetsStatus ($id)
 reset target status of a mass mailing
 
 settodraft ($id)
 Set a mass mailing to draft.
 
 validate ($id)
 Validate a mass mailing.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _cleanTargetDatas ($object)
 Clean sensible object (mailing target) datas.
 
 _cleanObjectDatas ($object)
 Clean sensible object datas @phpstan-template T.
 
- Protected Member Functions inherited from DolibarrApi
 _checkValForAPI ($field, $value, $object)
 Check and convert a string depending on its type/name.
 
 _checkValExtrafieldsForAPI ($field, $value, $object)
 Check and convert a string depending on its type/name.
 
 _filterObjectProperties ($object, $properties)
 Filter properties that will be returned on object.
 
 _checkFilters ($sqlfilters, &$error='')
 Return if a $sqlfilters parameter is valid Function no more used.
 

Private Member Functions

 _fetch ($id)
 Get properties of an mailing object.
 
 _fetchTarget ($id, $targetid)
 Get properties of an mailing object.
 
 _validate ($data)
 Validate fields before create or update object.
 
 _validateTarget ($data)
 Validate fields before create or update object.
 

Additional Inherited Members

- Static Protected Member Functions inherited from DolibarrApi
static _checkAccessToResource ($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
 Check access by user to a given resource.
 
static _forge_criteria_callback ($matches)
 Function to forge a SQL criteria from a Generic filter string.
 

Detailed Description

Definition at line 33 of file api_mailings.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Mailings::_cleanObjectDatas ( $object)
protected

Clean sensible object datas @phpstan-template T.

Parameters
Object$objectObject to clean
Returns
Object Object with cleaned properties @phpstan-param T $object @phpstan-return T

Reimplemented from DolibarrApi.

Definition at line 1158 of file api_mailings.class.php.

References $object.

Referenced by _fetch(), index(), settodraft(), and validate().

◆ _cleanTargetDatas()

Mailings::_cleanTargetDatas ( $object)
protected

Clean sensible object (mailing target) datas.

Parameters
Object$objectObject to clean
Returns
Object Object with cleaned properties

Definition at line 1021 of file api_mailings.class.php.

References $object.

Referenced by _fetchTarget(), and indexTargets().

◆ _fetch()

Mailings::_fetch ( $id)
private

Get properties of an mailing object.

Return an array with mailing information

Parameters
int$idID of mailing object
Returns
Object Object with cleaned properties
Exceptions
RestException

Definition at line 100 of file api_mailings.class.php.

References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

Referenced by get().

◆ _fetchTarget()

Mailings::_fetchTarget ( $id,
$targetid )
private

Get properties of an mailing object.

Return an array with mailing information

Parameters
int$idID of mailing object
int$targetidId mass mailing target
Returns
Object Object with cleaned properties
Exceptions
RestException403
RestException404

Definition at line 694 of file api_mailings.class.php.

References $id, DolibarrApi\_checkAccessToResource(), and _cleanTargetDatas().

Referenced by getTarget().

◆ _validate()

Mailings::_validate ( $data)
private

Validate fields before create or update object.

Parameters
?array<string,string>$data Array with data to verify
Returns
array<string,string>
Exceptions
RestException

Definition at line 976 of file api_mailings.class.php.

Referenced by post().

◆ _validateTarget()

Mailings::_validateTarget ( $data)
private

Validate fields before create or update object.

Parameters
?array<string,string>$data Array with data to verify
Returns
array<string,string>
Exceptions
RestException

Definition at line 999 of file api_mailings.class.php.

Referenced by postTarget().

◆ clone()

Mailings::clone ( $id,
$cloneContent = 1,
$cloneRecipients = 1,
$notrigger = 0 )

Clone a mass mailing.

Since
23.0.0 Initial implementation
Parameters
int$idId of object to clone
int$cloneContent1=Clone content (default), 0=Forget content
int$cloneRecipients1=Clone recipients (default), 0=Forget recipients
int$notrigger1=Disable triggers, 0=Active triggers if any (default)
Returns
Object Object with cleaned properties
Exceptions
RestException403
RestException404
RestException500 System error

Definition at line 356 of file api_mailings.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ delete()

Mailings::delete ( $id)

Delete a mass mailing.

Since
23.0.0 Initial implementation
Parameters
int$idMass mailing ID
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}
Exceptions
RestException403
RestException404
RestException500 System error

Definition at line 498 of file api_mailings.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ deleteTarget()

Mailings::deleteTarget ( $id,
$targetid )

Delete a mass mailing general fields (won't change lines of mass mailing)

Since
23.0.0 Initial implementation
Parameters
int$idId of mass mailing with the targetid to delete
int$targetidId mass mailing target to delete
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}

@url DELETE {id}/deleteTarget/{targetid}

Exceptions
RestException403
RestException404
RestException500 System error

Definition at line 740 of file api_mailings.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ deleteTargets()

Mailings::deleteTargets ( $id)

Delete targets of a mass mailing.

Since
23.0.0 Initial implementation
Parameters
int$idMass mailing ID
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}

@url DELETE {id}/deleteTargets

Exceptions
RestException403
RestException404
RestException500 System error

Definition at line 792 of file api_mailings.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ get()

Mailings::get ( $id)

Get a mass mailing.

Return an array with mass mailing information

Since
23.0.0 Initial implementation
Parameters
int$idID of mass mailing
Returns
Object Object with cleaned properties
Exceptions
RestException

Definition at line 85 of file api_mailings.class.php.

References $id, and _fetch().

◆ getTarget()

Mailings::getTarget ( $id,
$targetid )

Get a target in a mass mailing.

Return an array with info about a mass mailing target

Since
23.0.0 Initial implementation
Parameters
int$idId of mass mailing with the targetid to get
int$targetidId mass mailing target to get
Returns
Object Object with cleaned properties

@url GET {id}/getTarget/{targetid}

Exceptions
RestException

Definition at line 677 of file api_mailings.class.php.

References $id, and _fetchTarget().

Referenced by updateTarget().

◆ index()

Mailings::index ( $sortfield = "t.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$fk_projects = '',
$sqlfilters = '',
$properties = '',
$pagination_data = false,
$loadlinkedobjects = 0 )

List mass mailings.

Get a list of mass mailings

Since
23.0.0 Initial implementation
Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$fk_projectsProject ids to filter mass mailings (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'2016-01-01')"
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
bool$pagination_dataIf this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
int$loadlinkedobjectsLoad also linked object
Returns
array Array of order objects @phan-return Mailing[]|array{data:Mailing[],pagination:array{total:int,page:int,page_count:int,limit:int}} @phpstan-return Mailing[]|array{data:Mailing[],pagination:array{total:int,page:int,page_count:int,limit:int}}
Exceptions
RestException400
RestException403

Definition at line 147 of file api_mailings.class.php.

References DolibarrApi\_checkAccessToResource(), _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), and dol_syslog().

◆ indexTargets()

Mailings::indexTargets ( $id,
$sortfield = "t.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$sqlfilters = '',
$properties = '',
$pagination_data = false )

List mass mailing targets.

Get a list of mass mailing targets

Since
23.0.0 Initial implementation
Parameters
int$idMass mailing ID
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.lastname:like:'John Doe') and (t.statut:=:3)"
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
bool$pagination_dataIf this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
Returns
array Array of order objects @phan-return Mailing[]|array{data:Mailing[],pagination:array{total:int,page:int,page_count:int,limit:int}} @phpstan-return Mailing[]|array{data:Mailing[],pagination:array{total:int,page:int,page_count:int,limit:int}}

@url GET {id}/targets

Exceptions
RestException400
RestException403
RestException404

Definition at line 258 of file api_mailings.class.php.

References $id, DolibarrApi\_checkAccessToResource(), _cleanTargetDatas(), DolibarrApi\_filterObjectProperties(), and dol_syslog().

◆ post()

Mailings::post ( $request_data = null)

Create a mass mailing.

Since
23.0.0 Initial implementation
Parameters
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
int ID of mass mailing
Exceptions
RestException403
RestException500 System error

Definition at line 395 of file api_mailings.class.php.

References DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValForAPI(), _validate(), and sanitizeVal().

◆ postTarget()

Mailings::postTarget ( $id,
$request_data = null )

Create a mass mailing.

Since
23.0.0 Initial implementation
Parameters
int$idId of mass mailing to create a target for
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
int ID of mass mailing

@url POST {id}/createTarget

Exceptions
RestException400
RestException403
RestException404
RestException500 System error

Definition at line 612 of file api_mailings.class.php.

References DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValForAPI(), _validateTarget(), and sanitizeVal().

◆ put()

Mailings::put ( $id,
$request_data = null )

Update a mass mailing general fields (won't change lines of mass mailing)

Since
23.0.0 Initial implementation
Parameters
int$idId of mass mailing to update
array$request_dataDatas @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
Object Object with cleaned properties
Exceptions
RestException403
RestException404
RestException500 System error

Definition at line 440 of file api_mailings.class.php.

References $id, DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValExtrafieldsForAPI(), DolibarrApi\_checkValForAPI(), and sanitizeVal().

◆ resetTargetsStatus()

Mailings::resetTargetsStatus ( $id)

reset target status of a mass mailing

Since
23.0.0 Initial implementation
Parameters
int$idMass mailing ID
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}

@url PUT {id}/resetTargetsStatus

Exceptions
RestException403
RestException404
RestException500 System error

Definition at line 839 of file api_mailings.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ settodraft()

Mailings::settodraft ( $id)

Set a mass mailing to draft.

Since
23.0.0 Initial implementation
Parameters
int$idMass mailing ID
Returns
Object Object with cleaned properties

@url PUT {id}/settodraft

Exceptions
RestException304
RestException403
RestException404
RestException500 System error

Definition at line 885 of file api_mailings.class.php.

References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

◆ updateTarget()

Mailings::updateTarget ( $id,
$targetid,
$request_data = null )

Update a mass mailing general fields (won't change lines of mass mailing)

Since
23.0.0 Initial implementation
Parameters
int$idId of mass mailing with the targetid to update
int$targetidId mass mailing target to update
array$request_dataDatas @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
Object Object with cleaned properties

@url PUT {id}/updateTarget/{targetid}

Exceptions
RestException403
RestException404
RestException500 System error

Definition at line 546 of file api_mailings.class.php.

References $id, DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValForAPI(), getTarget(), and sanitizeVal().

◆ validate()

Mailings::validate ( $id)

Validate a mass mailing.

If you get a bad value for param notrigger check that ou provide this in body { "notrigger": 0 }

Since
23.0.0 Initial implementation
Parameters
int$idMass mailing ID
Returns
Object Object with cleaned properties

@url PUT {id}/validate

Exceptions
RestException304
RestException403
RestException404
RestException500 System error

Definition at line 937 of file api_mailings.class.php.

References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().


The documentation for this class was generated from the following file: