PHP Class NotificationTarget, glpi

Inheritance: extends CommonDBChild
Mostra file Open project: glpi-project/glpi Class Usage Examples

Public Properties

Property Type Description
$datas See https://forge.indepnet.net/projects/5/wiki/NotificationTemplatesTags
$dohistory From CommonDBTM
$entity
$events array of event name => event label
$html_tags Tags which have data in HTML : do not try to clean them
$items_id
$itemtype From CommonDBChild
$notification_targets
$notification_targets_labels
$notificationoptions
$obj Object which raises the notification event
$options
$prefix
$raiseevent
$table
$tag_descriptions
$target Array to store emails by notification
$target_object Object which is associated with the event

Public Methods

Method Description
__construct ( $entity = '', $event = '', $object = null, $options = [] )
addAdditionnalInfosForTarget ( )
addAdditionnalUserInfo ( array $data ) : empty
addGroupsToTargets ( $entity )
addProfilesToTargets ( )
addTagToList ( $options = [] )
addTarget ( $target = '', $label = '', $type = Notification::USER_TYPE )
addToAddressesList ( array $data ) Add new mail with lang to current email array
clearAddressesList ( )
countForGroup ( Group $group ) : integer Count Notification for a group
displayTabContentForItem ( CommonGLPI $item, $tabnum = 1, $withtemplate )
formatURL ( $usertype, $redirect )
getAdditionalTargets ( $event = '' ) Allows to add more notification targets Can be overridden in some case (for example Ticket)
getAddressesByGroup ( $manager, $group_id ) Get targets for all the users of a group
getAddressesByTarget ( $data, $options = [] ) Get addresses by type of notification
getAdminAddress ( ) Get GLPI's global administrator email
getAllEvents ( ) : an Return all (GLPI + plugins) notification events for the object type
getContentFooter ( ) Get footer to add to content
getContentHeader ( ) Get header to add to content
getDatasForTemplate ( $event, $options = [] ) Get all data needed for template processing Provides minimum information for alerts Can be overridden by each NotificationTartget class if needed
getDefaultUserType ( )
getDistinctUserSql ( )
getEntity ( )
getEntityAdminAddress ( ) Get entity admin email
getEvents ( ) : an Return main notification events for the object type Internal use only => should use getAllEvents
getForTemplate ( $event, $options )
getFromDBForTarget ( $notifications_id, $type, $ID ) : true Retrieve an item from the database for a specific target
getInstance ( $item, $event = '', $options = [] ) : a Get a notificationtarget class by giving the object which raises the event
getInstanceByType ( $itemtype, $event = '', $options = [] ) : a Get a notificationtarget class by giving an itemtype
getItemAuthorAddress ( ) Get the email of the item's user
getItemGroupAddress ( ) Get Group of the item
getItemGroupSupervisorAddress ( ) Get Group supervisor of the item
getItemGroupTechInChargeAddress ( ) Get Group of technicians in charge of the item
getItemGroupWithoutSupervisorAddress ( ) Get Group without supervisor of the item
getItemOwnerAddress ( ) Get user owner of the material
getItemTechnicianInChargeAddress ( ) Get technician in charge of the item
getMessageID ( ) : message
getNotificationTargets ( $entity ) Return all the targets for this notification Values returned by this method are the ones for the alerts Can be updated by implementing the getAdditionnalTargets() method Can be overwitten (like dbconnection)
getObjectItem ( $event = '' ) : the Get item associated with the object on which the event was raised
getProfileJoinSql ( )
getRawName ( ) Get a notificationtarget class by giving the object which raises the event
getReplyTo ( $options = [] ) : the Get the reply to address
getSender ( $options = [] ) : the Get admin which sends the notification
getSpecificTargets ( $data, $options ) Get addresses by a method not defined in NotificationTarget (specific to an itemtype)
getSubjectPrefix ( $event = '' )
getTabNameForItem ( CommonGLPI $item, $withtemplate )
getTable ( ) Temporary hack for this class since 0.84
getTags ( )
getTargets ( )
getTypeName ( $nb )
getUserByField ( $field, $search_in_object = false ) Add user to the notified users list
getUsersAddressesByProfile ( $profiles_id ) : nothing Get users emails by profile
showForGroup ( Group $group ) : nothing Display notification registered for a group
showForNotification ( Notification $notification )
updateTargets ( $input )
validateSendTo ( $event, array $infos, $notify_me = false ) : true Validate send before doing it (may be overloaded : exemple for private tasks or followups)

Method Details

__construct() public method

public __construct ( $entity = '', $event = '', $object = null, $options = [] )
$entity (default '')
$event (default '')
$object (default null)
$options array

addAdditionnalInfosForTarget() public method

addAdditionnalUserInfo() public method

public addAdditionnalUserInfo ( array $data ) : empty
$data array
return empty array

addGroupsToTargets() public method

public addGroupsToTargets ( $entity )
$entity

addProfilesToTargets() public method

addTagToList() public method

public addTagToList ( $options = [] )
$options array

addTarget() public method

public addTarget ( $target = '', $label = '', $type = Notification::USER_TYPE )
$target (default '')
$label (default '')
$type (=Notification::USER_TYPE)

addToAddressesList() public method

Add new mail with lang to current email array
public addToAddressesList ( array $data )
$data array array of data (mail, lang[, id for user])

clearAddressesList() public method

public clearAddressesList ( )

countForGroup() static public method

Count Notification for a group
static public countForGroup ( Group $group ) : integer
$group Group Group object
return integer

displayTabContentForItem() static public method

static public displayTabContentForItem ( CommonGLPI $item, $tabnum = 1, $withtemplate )
$item CommonGLPI

formatURL() public method

public formatURL ( $usertype, $redirect )
$usertype
$redirect

getAdditionalTargets() public method

Allows to add more notification targets Can be overridden in some case (for example Ticket)
public getAdditionalTargets ( $event = '' )
$event specif event to get additional targets (default '')

getAddressesByGroup() public method

Get targets for all the users of a group
public getAddressesByGroup ( $manager, $group_id )
$manager 0 all users, 1 only supervisors, 2 all users without supervisors
$group_id id of the group

getAddressesByTarget() public method

Get addresses by type of notification
public getAddressesByTarget ( $data, $options = [] )
$data
$options array

getAdminAddress() public method

Get GLPI's global administrator email
public getAdminAddress ( )

getAllEvents() public method

Return all (GLPI + plugins) notification events for the object type
public getAllEvents ( ) : an
return an array which contains : event => event label

getContentFooter() public method

Get footer to add to content
public getContentFooter ( )

getContentHeader() public method

Get header to add to content
public getContentHeader ( )

getDatasForTemplate() public method

Get all data needed for template processing Provides minimum information for alerts Can be overridden by each NotificationTartget class if needed
public getDatasForTemplate ( $event, $options = [] )
$event
$options array

getDefaultUserType() public method

public getDefaultUserType ( )

getDistinctUserSql() public method

public getDistinctUserSql ( )

getEntity() public method

public getEntity ( )

getEntityAdminAddress() public method

Get entity admin email

getEvents() public method

Return main notification events for the object type Internal use only => should use getAllEvents
public getEvents ( ) : an
return an array which contains : event => event label

getForTemplate() public method

public getForTemplate ( $event, $options )
$event
$options

getFromDBForTarget() public method

Retrieve an item from the database for a specific target
public getFromDBForTarget ( $notifications_id, $type, $ID ) : true
$notifications_id integer notification ID
$type type of the target to retrive
$ID integer ID of the target to retrieve
return true if succeed else false

getInstance() static public method

Get a notificationtarget class by giving the object which raises the event
static public getInstance ( $item, $event = '', $options = [] ) : a
$item the object which raises the event
$event the event which will be used (default '')
$options array of options
return a notificationtarget class or false

getInstanceByType() static public method

Get a notificationtarget class by giving an itemtype
static public getInstanceByType ( $itemtype, $event = '', $options = [] ) : a
$itemtype the itemtype of the object which raises the event
$event the event which will be used (default '')
$options array of options
return a notificationtarget class or false

getItemAuthorAddress() public method

Get the email of the item's user

getItemGroupAddress() public method

Get Group of the item
public getItemGroupAddress ( )

getItemGroupSupervisorAddress() public method

Get Group supervisor of the item

getItemGroupTechInChargeAddress() public method

Get Group of technicians in charge of the item

getItemGroupWithoutSupervisorAddress() public method

Get Group without supervisor of the item

getItemOwnerAddress() public method

Get user owner of the material
public getItemOwnerAddress ( )

getItemTechnicianInChargeAddress() public method

Get technician in charge of the item

getMessageID() public method

public getMessageID ( ) : message
return message id for notification

getNotificationTargets() public method

Return all the targets for this notification Values returned by this method are the ones for the alerts Can be updated by implementing the getAdditionnalTargets() method Can be overwitten (like dbconnection)
public getNotificationTargets ( $entity )
$entity the entity on which the event is raised

getObjectItem() public method

Get item associated with the object on which the event was raised
public getObjectItem ( $event = '' ) : the
$event (default '')
return the object associated with the itemtype

getProfileJoinSql() public method

public getProfileJoinSql ( )

getRawName() public method

Get a notificationtarget class by giving the object which raises the event
See also: CommonDBTM::getRawName
public getRawName ( )

getReplyTo() public method

Get the reply to address
public getReplyTo ( $options = [] ) : the
$options array
return the reply to address

getSender() public method

Get admin which sends the notification
public getSender ( $options = [] ) : the
$options array
return the sender's address

getSpecificTargets() public method

Get addresses by a method not defined in NotificationTarget (specific to an itemtype)
public getSpecificTargets ( $data, $options )
$data
$options

getSubjectPrefix() public method

public getSubjectPrefix ( $event = '' )
$event (default '')

getTabNameForItem() public method

public getTabNameForItem ( CommonGLPI $item, $withtemplate )
$item CommonGLPI

getTable() static public method

Temporary hack for this class since 0.84
static public getTable ( )

getTags() public method

public getTags ( )

getTargets() public method

public getTargets ( )

getTypeName() static public method

static public getTypeName ( $nb )

getUserByField() public method

Add user to the notified users list
public getUserByField ( $field, $search_in_object = false )
$field look for user looking for this field in the object which raises the event
$search_in_object search is done in the object ? if not in target object (false by default)

getUsersAddressesByProfile() public method

Get users emails by profile
public getUsersAddressesByProfile ( $profiles_id ) : nothing
$profiles_id the profile ID to get users emails
return nothing

showForGroup() static public method

Display notification registered for a group
static public showForGroup ( Group $group ) : nothing
$group Group Group object
return nothing

showForNotification() public method

public showForNotification ( Notification $notification )
$notification Notification Notification object

updateTargets() static public method

static public updateTargets ( $input )
$input

validateSendTo() public method

Validate send before doing it (may be overloaded : exemple for private tasks or followups)
public validateSendTo ( $event, array $infos, $notify_me = false ) : true
$event string notification event
$infos array array of destination of the notification
$notify_me boolean notify me on my action ? ($infos contains users_id to check if the target is me) (false by default)
return true

Property Details

$datas public_oe property

See https://forge.indepnet.net/projects/5/wiki/NotificationTemplatesTags
public $datas

$dohistory public_oe property

From CommonDBTM
public $dohistory

$entity public_oe property

public $entity

$events public_oe property

array of event name => event label
public $events

$html_tags public_oe property

Tags which have data in HTML : do not try to clean them
public $html_tags

$items_id public_oe static_oe property

public static $items_id

$itemtype public_oe static_oe property

From CommonDBChild
public static $itemtype

$notification_targets public_oe property

public $notification_targets

$notification_targets_labels public_oe property

public $notification_targets_labels

$notificationoptions public_oe property

public $notificationoptions

$obj public_oe property

Object which raises the notification event
public $obj

$options public_oe property

public $options

$prefix public_oe property

public $prefix

$raiseevent public_oe property

public $raiseevent

$table public_oe property

public $table

$tag_descriptions public_oe property

public $tag_descriptions

$target public_oe property

Array to store emails by notification
public $target

$target_object public_oe property

Object which is associated with the event
public $target_object