dolibarr 24.0.0-beta
Notify Class Reference

Class to manage the table of subscription to notifications. More...

Collaboration diagram for Notify:

Public Member Functions

 __construct ($db)
 Constructor.
 
 confirmMessage ($action, $socid, $object)
 Return message that say how many notification (and to which email) will occurs on requested event.
 
 delete ($user=null)
 Delete a notification from database.
 
 create ($user=null, $notrigger=0)
 Create notification information record.
 
 fetch ($id, $socid=0, $type='email')
 Load record from database.
 
 update ($user=null, $notrigger=0)
 Update record in database.
 
 getNotificationsArray ($notifcode, $socid=0, $object=null, $userid=0, $scope=array('thirdparty', 'user', 'global'))
 Return number of notifications activated, for all or a given action code (and third party)
 
 send ($notifcode, $object, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array())
 Check if notification are active for couple action/company.
 

Private Member Functions

 getSupervisorEmail ($withLabel=0)
 Return supervisor email.
 
 getAuthorEmail ($object, $withLabel=0)
 Return author email of object.
 
 replaceSpecialRecipientToken ($sendto, $token, $replacement)
 Replace a special token inside recipient list.
 

Detailed Description

Class to manage the table of subscription to notifications.

Definition at line 39 of file notify.class.php.

Constructor & Destructor Documentation

◆ __construct()

Notify::__construct ( $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

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

Member Function Documentation

◆ confirmMessage()

Notify::confirmMessage ( $action,
$socid,
$object )

Return message that say how many notification (and to which email) will occurs on requested event.

This is to show confirmation messages before event is recorded.

Parameters
string$actionId of action in llx_c_action_trigger
int$socidId of third party
?CommonObject$objectObject the notification is about
Returns
string Message

Definition at line 200 of file notify.class.php.

References $object, getDolGlobalString(), getNotificationsArray(), and img_object().

◆ create()

Notify::create ( $user = null,
$notrigger = 0 )

Create notification information record.

Parameters
?User$userUser
int<0,1>$notrigger 1=Disable triggers
Returns
int Return integer <0 if KO, > 0 if OK (ID of newly created company notification information)

Definition at line 311 of file notify.class.php.

References dol_now(), and type.

◆ delete()

Notify::delete ( $user = null)

Delete a notification from database.

Parameters
?User$userUser deleting
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 277 of file notify.class.php.

References dol_syslog().

◆ fetch()

Notify::fetch ( $id,
$socid = 0,
$type = 'email' )

Load record from database.

Parameters
int$idId of record
int$socidId of company. If this is filled, function will return only records belonging to this thirdparty
string$typeIf id of company filled, we say if we want record of this type only
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 362 of file notify.class.php.

References dol_print_error(), email, and type.

◆ getAuthorEmail()

Notify::getAuthorEmail ( $object,
$withLabel = 0 )
private

Return author email of object.

Parameters
CommonObject | null$objectObject used to resolve author
int<0,1>$withLabel 1=Return "Firstname Lastname <email>", 0=Return "email"
Returns
string

Definition at line 1412 of file notify.class.php.

References $object, and dolGetFirstLastname().

Referenced by getNotificationsArray(), and send().

◆ getNotificationsArray()

Notify::getNotificationsArray ( $notifcode,
$socid = 0,
$object = null,
$userid = 0,
$scope = array('thirdparty', 'user', 'global') )

Return number of notifications activated, for all or a given action code (and third party)

Parameters
string$notifcodeCode of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
int$socidId of third party or 0 for all thirdparties or -1 for no thirdparties
?CommonObject$objectObject the notification is about (need it to check threshold value of some notifications)
int$useridId of user or 0 for all users or -1 for no users
string[]$scopeScope where to search
Returns
array<string,array{type:'touser'|'tofixedemail',code:string,emaildesc:string,email:string,userid:int,isemailvalid:bool}>|-1 Return integer <0 if KO, array of notifications to send if OK

Definition at line 466 of file notify.class.php.

References $conf, $object, dol_syslog(), getAuthorEmail(), getSupervisorEmail(), and isValidEmail().

Referenced by confirmMessage().

◆ getSupervisorEmail()

Notify::getSupervisorEmail ( $withLabel = 0)
private

Return supervisor email.

Parameters
int<0,1>$withLabel 1=Return "Firstname Lastname <email>", 0=Return "email"
Returns
string

Definition at line 1384 of file notify.class.php.

References dolGetFirstLastname().

Referenced by getNotificationsArray(), and send().

◆ replaceSpecialRecipientToken()

Notify::replaceSpecialRecipientToken ( $sendto,
$token,
$replacement )
private

Replace a special token inside recipient list.

Parameters
string$sendtoRecipient list
string$tokenToken to replace
string$replacementReplacement value
Returns
string

Definition at line 1458 of file notify.class.php.

References dol_syslog().

Referenced by send().

◆ send()

Notify::send ( $notifcode,
$object,
$filename_list = array(),
$mimetype_list = array(),
$mimefilename_list = array() )

Check if notification are active for couple action/company.

If yes, send mail and save trace into llx_notify.

Parameters
string$notifcodeCode of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
CommonObject$objectObject the notification deals on
string[]$filename_listList of files to attach (full path of filename on file system)
string[]$mimetype_listList of MIME type of attached files
string[]$mimefilename_listList of attached file name in message
Returns
int Return integer <0 if KO, or number of changes if OK

Definition at line 627 of file notify.class.php.

References $conf, $dolibarr_main_url_root, $mysoc, $object, complete_substitutions_array(), dol_getIdFromCode(), dol_is_file(), dol_now(), dol_print_error(), dol_sanitizeFileName(), dol_strlen(), dol_syslog(), dolGetFirstLastname(), get_exdir(), getAuthorEmail(), getDolGlobalString(), getSupervisorEmail(), make_substitutions(), and replaceSpecialRecipientToken().

◆ update()

Notify::update ( $user = null,
$notrigger = 0 )

Update record in database.

Parameters
?User$userObject user
int<0,1>$notrigger 1=Disable triggers
Returns
int Return integer <=0 if KO, >0 if OK

Definition at line 413 of file notify.class.php.

References type.


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