class Notify (View source)

Class to manage the table of subscription to notifications

Properties

int $id
DoliDB $db
string $type
string $threshold
string $context
int $event
int $socid
int $contact_id
int $fk_user
string $email
int $datec

Date creation record (datec)

int $datem

Date modified record (datem)

string $error
string[] $errors
string $author
string $ref
int $date
int $duree
string $note
int $fk_project
static $arrayofnotifsupported

Methods

__construct(DoliDB $db)

Constructor

string
confirmMessage(string $action, $socid, $object)

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

delete(User $user = null)

Delete a notification from database

int
create(User $user = null, int<0, 1> $notrigger = 0)

Create notification information record.

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

Load record from database

int
update(User $user = null, $notrigger = 0)

Update record in database

array|int
getNotificationsArray(string $notifcode, int $socid = 0, CommonObject $object = null, int $userid = 0, array $scope = array('thirdparty', 'user', 'global'))

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

int
send(string $notifcode, $object, string[] $filename_list = array(), string[] $mimetype_list = array(), string[] $mimefilename_list = array())

Check if notification are active for couple action/company.

Details

__construct(DoliDB $db)

Constructor

Parameters

DoliDB $db

Database handler

string confirmMessage(string $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 $action

Id of action in llx_c_action_trigger @param int $socid Id of third party @param Object $object Object the notification is about

$socid
$object

Return Value

string Message

delete(User $user = null)

Delete a notification from database

Parameters

User $user

User deleting @return int Return integer <0 if KO, >0 if OK

int create(User $user = null, int<0, 1> $notrigger = 0)

Create notification information record.

Parameters

User $user User
int<0, 1> $notrigger

1=Disable triggers

Return Value

int

Return integer <0 if KO, > 0 if OK (ID of newly created company notification information)

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

Load record from database

Parameters

int $id

Id of record @param int $socid Id of company. If this is filled, function will return only records belonging to this thirdparty @param string $type If id of company filled, we say if we want record of this type only @return int Return integer <0 if KO, >0 if OK

$socid
$type

int update(User $user = null, $notrigger = 0)

Update record in database

Parameters

User $user

Object user @param int<0,1> $notrigger 1=Disable triggers

$notrigger

Return Value

int

Return integer <=0 if KO, >0 if OK

array|int getNotificationsArray(string $notifcode, int $socid = 0, CommonObject $object = null, int $userid = 0, array $scope = array('thirdparty', 'user', 'global'))

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

Parameters

string $notifcode

Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)

int $socid

Id of third party or 0 for all thirdparties or -1 for no thirdparties

CommonObject $object

Object the notification is about (need it to check threshold value of some notifications)

int $userid

Id of user or 0 for all users or -1 for no users

array $scope

Scope where to search

Return Value

array|int

Return integer <0 if KO, array of notifications to send if OK

int send(string $notifcode, $object, string[] $filename_list = array(), string[] $mimetype_list = array(), string[] $mimefilename_list = array())

Check if notification are active for couple action/company.

If yes, send mail and save trace into llx_notify.

Parameters

string $notifcode

Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage) @param CommonObject $object Object the notification deals on

$object
string[] $filename_list

List of files to attach (full path of filename on file system)

string[] $mimetype_list

List of MIME type of attached files

string[] $mimefilename_list

List of attached file name in message

Return Value

int

Return integer <0 if KO, or number of changes if OK