PHP Class MailCollector, glpi

Inheritance: extends CommonDBTM
Mostrar archivo Open project: glpi-project/glpi Class Usage Examples

Public Properties

Property Type Description
$addtobody Message to add to body to build ticket
$altfiles structure used to store alt files attached to a mail
$body_converted Body converted
$charset working charset of the mail
$dohistory
$fetch_emails Number of fetched emails
$files structure used to store files attached to a mail
$filesize_max Max size for attached files
$marubox IMAP / POP connection
$maxfetch_emails Maximum number of emails to fetch : default to 10
$mid ID of the current message
$rightname
$structure structure used to store the mail structure
$tags Tag used to recognize embedded images of a mail

Public Methods

Method Description
buildTicket ( $i, $options = [] ) : ticket function buildTicket - Builds,and returns, the major structure of the ticket to be entered.
canCreate ( )
canPurge ( )
cleanDBonPurge ( )
cleanMailContent ( $string, $striptags = true ) : cleaned Clean mail content : HTML + XSS + blacklisted content
close_mailbox ( ) Close The Mail Box
collect ( $mailgateID, $display ) : if Constructor
connect ( ) Connect to the mail box
cronInfo ( $name )
cronMailgate ( $task ) : -1 Cron action on mailgate : retrieve mail and create tickets
cronMailgateError ( $task ) Send Alarms on mailgate errors
decodeMimeString ( $mimeStr, $inputCharset = 'utf-8', $targetCharset = 'utf-8', $fallbackCharset = 'iso-8859-1' ) : decoded Receive a string with a mail header and returns it decoded to a specified charset.
defineTabs ( $options = [] )
deleteMails ( $mid, $folder = '' ) : boolean Delete mail from that mail box
deleteOrImportSeveralEmails ( $emails_ids = [], $action, $entity )
displayTabContentForItem ( CommonGLPI $item, $tabnum = 1, $withtemplate )
getAdditionalMenuOptions ( )
getAdditionnalHeaders ( $mid )
getAttached ( $mid, $path, $maxsize ) : array Public function : get attached documents in a mail
getBody ( $mid ) Get The actual mail content from this mail
getHeaders ( $mid ) : Return This function is use full to Get Header info from particular mail
getNumberOfActiveMailCollectors ( )
getNumberOfMailCollectors ( )
getRecursiveAttached ( $mid, $path, $maxsize, $structure, $part = "" ) Private function : Recursivly get attached documents
getSearchOptions ( )
getStructure ( $mid ) get the message structure if not already retrieved
getTabNameForItem ( CommonGLPI $item, $withtemplate )
getTotalMails ( ) : an Used to get total unread mail from that mailbox
getTypeName ( $nb )
get_mime_type ( &$structure ) : mime Get Mime type Internal Private Use
get_part ( $stream, $msg_number, $mime_type, $structure = false, $part_number = false ) : data Get Part Of Message Internal Private Use
mb_list_lowerencodings ( ) return supported encodings in lowercase.
post_getEmpty ( )
prepareInputForAdd ( $input )
prepareInputForUpdate ( $input )
sendMailRefusedResponse ( $to = '', $subject = '' )
showForm ( $ID, $options = [] ) : boolean Print the mailgate form
showGetMessageForm ( $ID )
showMaxFilesize ( $name, $value )
showSystemInformations ( $width )
textCleaner ( $text ) : clean function textCleaner - Strip out unwanted/unprintable characters from the subject.
title ( )
unsetUndisclosedFields ( &$fields )

Private Methods

Method Description
getDecodedFetchbody ( $structure, $mid, $part ) : boolean | string Summary of getDecodedFetchbody used to get decoded part from email

Method Details

buildTicket() public method

function buildTicket - Builds,and returns, the major structure of the ticket to be entered.
public buildTicket ( $i, $options = [] ) : ticket
$i mail ID
$options array of possible options
return ticket fields array

canCreate() static public method

static public canCreate ( )

canPurge() static public method

static public canPurge ( )

cleanDBonPurge() public method

public cleanDBonPurge ( )

cleanMailContent() public method

Clean mail content : HTML + XSS + blacklisted content
public cleanMailContent ( $string, $striptags = true ) : cleaned
$string text to clean
$striptags remove html tags
return cleaned text

close_mailbox() public method

Close The Mail Box
public close_mailbox ( )

collect() public method

Constructor
public collect ( $mailgateID, $display ) : if
$mailgateID ID of the mailgate
$display display messages in MessageAfterRedirect or just return error (default 0=)
return if $display = false return messages result string

connect() public method

Connect to the mail box
public connect ( )

cronInfo() static public method

static public cronInfo ( $name )
$name

cronMailgate() static public method

Cron action on mailgate : retrieve mail and create tickets
static public cronMailgate ( $task ) : -1
$task
return -1

cronMailgateError() static public method

Send Alarms on mailgate errors
static public cronMailgateError ( $task )
$task for log

decodeMimeString() public method

If the charset specified into a piece of text from header isn't supported by "mb", the "fallbackCharset" will be used to try to decode it.
public decodeMimeString ( $mimeStr, $inputCharset = 'utf-8', $targetCharset = 'utf-8', $fallbackCharset = 'iso-8859-1' ) : decoded
$mimeStr mime header string
$inputCharset input charset (default 'utf-8')
$targetCharset target charset (default 'utf-8')
$fallbackCharset charset used if input charset not supported by mb (default 'iso-8859-1')
return decoded string

defineTabs() public method

See also: CommonGLPI::defineTabs()
public defineTabs ( $options = [] )

deleteMails() public method

Delete mail from that mail box
public deleteMails ( $mid, $folder = '' ) : boolean
$mid String mail Id
$folder String folder to move (delete if empty) (default '')
return boolean

deleteOrImportSeveralEmails() public method

public deleteOrImportSeveralEmails ( $emails_ids = [], $action, $entity )
$emails_ids array
$action (default 0)
$entity (default 0)

displayTabContentForItem() static public method

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

getAdditionalMenuOptions() static public method

See also: CommonGLPI::getAdditionalMenuOptions()
static public getAdditionalMenuOptions ( )

getAdditionnalHeaders() public method

public getAdditionnalHeaders ( $mid )
$mid

getAttached() public method

Public function : get attached documents in a mail
public getAttached ( $mid, $path, $maxsize ) : array
$mid message id
$path temporary path
$maxsize of document to be retrieved
return array containing extracted filenames in file/_tmp

getBody() public method

Get The actual mail content from this mail
public getBody ( $mid )
$mid : mail Id

getHeaders() public method

This function is use full to Get Header info from particular mail
public getHeaders ( $mid ) : Return
$mid = Mail Id of a Mailbox
return Return Associative array with following keys subject => Subject of Mail to => To Address of that mail toOth => Other To address of mail toNameOth => To Name of Mail from => From address of mail fromName => Form Name of Mail

getNumberOfActiveMailCollectors() static public method

getNumberOfMailCollectors() static public method

static public getNumberOfMailCollectors ( )

getRecursiveAttached() public method

Private function : Recursivly get attached documents
public getRecursiveAttached ( $mid, $path, $maxsize, $structure, $part = "" )
$mid message id
$path temporary path
$maxsize of document to be retrieved
$structure of the message or part
$part part for recursive Result is stored in $this->files

getSearchOptions() public method

public getSearchOptions ( )

getStructure() public method

get the message structure if not already retrieved
public getStructure ( $mid )
$mid : Message ID.

getTabNameForItem() public method

See also: CommonGLPI::getTabNameForItem()
public getTabNameForItem ( CommonGLPI $item, $withtemplate )
$item CommonGLPI

getTotalMails() public method

Used to get total unread mail from that mailbox
public getTotalMails ( ) : an
return an integer (Total Mail)

getTypeName() static public method

static public getTypeName ( $nb )

get_mime_type() public method

Get Mime type Internal Private Use
public get_mime_type ( &$structure ) : mime
$structure mail structure
return mime type

get_part() public method

Get Part Of Message Internal Private Use
public get_part ( $stream, $msg_number, $mime_type, $structure = false, $part_number = false ) : data
$stream An IMAP stream returned by imap_open
$msg_number The message number
$mime_type mime type of the mail
$structure structure of the mail (false by default)
$part_number The part number (false by default)
return data of false if error

mb_list_lowerencodings() public method

return supported encodings in lowercase.

post_getEmpty() public method

public post_getEmpty ( )

prepareInputForAdd() public method

See also: CommonDBTM::prepareInputForAdd()
public prepareInputForAdd ( $input )

prepareInputForUpdate() public method

See also: CommonDBTM::prepareInputForUpdate()
public prepareInputForUpdate ( $input )

sendMailRefusedResponse() public method

public sendMailRefusedResponse ( $to = '', $subject = '' )
$to (default '')
$subject (default '')

showForm() public method

Print the mailgate form
public showForm ( $ID, $options = [] ) : boolean
$ID integer Id of the item to print
$options array - target filename : where to go when done.
return boolean item found

showGetMessageForm() public method

public showGetMessageForm ( $ID )
$ID

showMaxFilesize() static public method

static public showMaxFilesize ( $name, $value )
$name
$value (default 0)

showSystemInformations() public method

public showSystemInformations ( $width )
$width

textCleaner() public method

function textCleaner - Strip out unwanted/unprintable characters from the subject.
public textCleaner ( $text ) : clean
$text text to clean
return clean text

title() public method

public title ( )

unsetUndisclosedFields() public static method

public static unsetUndisclosedFields ( &$fields )

Property Details

$addtobody public_oe property

Message to add to body to build ticket
public $addtobody

$altfiles public_oe property

structure used to store alt files attached to a mail
public $altfiles

$body_converted public_oe property

Body converted
public $body_converted

$charset public_oe property

working charset of the mail
public $charset

$dohistory public_oe property

public $dohistory

$fetch_emails public_oe property

Number of fetched emails
public $fetch_emails

$files public_oe property

structure used to store files attached to a mail
public $files

$filesize_max public_oe property

Max size for attached files
public $filesize_max

$marubox public_oe property

IMAP / POP connection
public $marubox

$maxfetch_emails public_oe property

Maximum number of emails to fetch : default to 10
public $maxfetch_emails

$mid public_oe property

ID of the current message
public $mid

$rightname static_oe public_oe property

static public $rightname

$structure public_oe property

structure used to store the mail structure
public $structure

$tags public_oe property

Tag used to recognize embedded images of a mail
public $tags