dolibarr 23.0.3
EmailTemplates Class Reference
Inheritance diagram for EmailTemplates:
Collaboration diagram for EmailTemplates:

Public Member Functions

 __construct ()
 Constructor of the class.
 
 deleteById ($id)
 Delete an email template.
 
 deleteByLAbel ($label)
 Delete an email template.
 
 getById ($id)
 Get properties of a email template by id.
 
 getByLabel ($label)
 Get properties of an email template by label.
 
 index ($sortfield="e.rowid", $sortorder='ASC', $limit=100, $page=0, $fk_user='', $sqlfilters='', $properties='', $pagination_data=false)
 List email templates.
 
 post ($request_data=null)
 Create an email template.
 
 putById ($id, $request_data=null)
 Update an email template.
 
 putbyLabel ($label, $request_data=null)
 Update an email template.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _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.
 
 _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, $label='')
 Get properties of an email template.
 
 _validate ($data)
 Validate fields before create or update object.
 
 _checkAccessRights ($accesstype)
 function to check for access rights - should probably have 1.
 

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 32 of file api_emailtemplates.class.php.

Member Function Documentation

◆ _checkAccessRights()

EmailTemplates::_checkAccessRights ( $accesstype)
private

function to check for access rights - should probably have 1.

parameter which is read/write/delete/... Why a separate function? because we probably needs to check so many many different kinds of objects

Parameters
string$accesstypeaccesstype: read, write, delete, ...
Returns
bool Return true if access is granted else false
Exceptions
RestException403

Definition at line 630 of file api_emailtemplates.class.php.

References isModEnabled().

Referenced by _fetch(), deleteById(), deleteByLAbel(), index(), post(), putById(), and putbyLabel().

◆ _cleanObjectDatas()

EmailTemplates::_cleanObjectDatas ( $object)
protected

Clean sensible object datas @phpstan-template T.

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

Reimplemented from DolibarrApi.

Definition at line 514 of file api_emailtemplates.class.php.

References $object, and dol_syslog().

Referenced by _fetch(), and index().

◆ _fetch()

EmailTemplates::_fetch ( $id,
$label = '' )
private

Get properties of an email template.

Return an array with email templates

Parameters
int$idID of email_template
string$labelLabel of email_template
Returns
Object Object with cleaned properties @phan-return CEmailTemplate @phpstan-return CEmailTemplate
Exceptions
RestException400
RestException403
RestException404

Definition at line 471 of file api_emailtemplates.class.php.

References $id, _checkAccessRights(), and _cleanObjectDatas().

Referenced by getById(), getByLabel(), putById(), and putbyLabel().

◆ _validate()

EmailTemplates::_validate ( $data)
private

Validate fields before create or update object.

Parameters
?array<string,null|int|string>$data Data to validate
Returns
array<string,null|int|string> Return array with validated mandatory fields and their value @phan-return array<string,?int|?string> Return array with validated mandatory fields and their value
Exceptions
RestException400

Definition at line 609 of file api_emailtemplates.class.php.

Referenced by post().

◆ deleteById()

EmailTemplates::deleteById ( $id)

Delete an email template.

Parameters
int$idemail template ID
Returns
array @phan-return array<array<string,int|string>> @phpstan-return array<array<string,int|string>>

@url DELETE {id}

Exceptions
RestException403
RestException404
RestException500

Definition at line 88 of file api_emailtemplates.class.php.

References $id, and _checkAccessRights().

◆ deleteByLAbel()

EmailTemplates::deleteByLAbel ( $label)

Delete an email template.

Parameters
string$labelemail template label
Returns
array @phan-return array<array<string,int|string>> @phpstan-return array<array<string,int|string>>

@url DELETE label/{label}

Exceptions
RestException403
RestException404
RestException500

Definition at line 126 of file api_emailtemplates.class.php.

References _checkAccessRights().

◆ getById()

EmailTemplates::getById ( $id)

Get properties of a email template by id.

Return an array with email template information

Parameters
int$idID of email template
Returns
Object Object with cleaned properties @phan-return CEmailTemplate @phpstan-return CEmailTemplate

@url GET {id}

Exceptions
RestException403
RestException404

Definition at line 165 of file api_emailtemplates.class.php.

References $id, and _fetch().

◆ getByLabel()

EmailTemplates::getByLabel ( $label)

Get properties of an email template by label.

Return an array with order information

Parameters
string$labelLabel of object
Returns
Object Object with cleaned properties @phan-return CEmailTemplate @phpstan-return CEmailTemplate

@url GET label/{label}

Exceptions
RestException403
RestException404

Definition at line 185 of file api_emailtemplates.class.php.

References _fetch().

◆ index()

EmailTemplates::index ( $sortfield = "e.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$fk_user = '',
$sqlfilters = '',
$properties = '',
$pagination_data = false )

List email templates.

Get a list of email templates

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$fk_userUser ids to filter email templates of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(e.active:=:1) and (e.module:=:'adherent')"
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 CEmailTemplate[]|array{data:CEmailTemplate[],pagination:array{total:int,page:int,page_count:int,limit:int}} @phpstan-return CEmailTemplate[]|array{data:CEmailTemplate[],pagination:array{total:int,page:int,page_count:int,limit:int}}

@url GET

Exceptions
RestException404 Not found
RestException503 Error

Definition at line 212 of file api_emailtemplates.class.php.

References _checkAccessRights(), _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), dol_syslog(), and forgeSQLFromUniversalSearchCriteria().

◆ post()

EmailTemplates::post ( $request_data = null)

Create an email template.

Example: {"module":"adherent","type_template":"member","active": 1,"label":"(SendingEmailOnAutoSubscription)","fk_user":0,"joinfiles": "0", ... } Required: {"label":"myBestTemplate","topic":"myBestOffer","type_template":"propal_send"}

Parameters
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

@url POST

Returns
int ID of email template
Exceptions
RestException400
RestException403
RestException500

Definition at line 308 of file api_emailtemplates.class.php.

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

◆ putById()

EmailTemplates::putById ( $id,
$request_data = null )

Update an email template.

Example: {"module":"adherent","type_template":"member","active": 1,"label":"(SendingEmailOnAutoSubscription)","fk_user":0,"joinfiles": "0", ... } Required: {"label":"myBestTemplate","topic":"myBestOffer","type_template":"propal_send"}

Parameters
int$idId of order to update
array$request_dataData @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

@url PUT {id}

Returns
Object Object with cleaned properties
Exceptions
RestException400
RestException403
RestException404
RestException500

Definition at line 361 of file api_emailtemplates.class.php.

References $id, _checkAccessRights(), DolibarrApi\_checkValForAPI(), _fetch(), and sanitizeVal().

◆ putbyLabel()

EmailTemplates::putbyLabel ( $label,
$request_data = null )

Update an email template.

Example: {"module":"adherent","type_template":"member","active": 1,"label":"(SendingEmailOnAutoSubscription)","fk_user":0,"joinfiles": "0", ... } Required: {"label":"myBestTemplate","topic":"myBestOffer","type_template":"propal_send"}

Parameters
string$labelLabel of order to update
array$request_dataData @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

@url PUT label/{label}

Returns
Object Object with cleaned properties
Exceptions
RestException400
RestException404
RestException500

Definition at line 416 of file api_emailtemplates.class.php.

References _checkAccessRights(), DolibarrApi\_checkValForAPI(), _fetch(), and sanitizeVal().


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