jbostoen / iTop-custom-extensions

Extensions for iTop . New classes (SIM cards, Monitors, IP Devices), more powerful Mail to Ticket automation, basic info on pro extensions such as geometry and ticket merge, some concepts (Check Out system), several small tweaks.
GNU General Public License v3.0
36 stars 13 forks source link

Mail to Ticket Automation - ignore/remove patterns in title #24

Closed jbostoen closed 6 years ago

jbostoen commented 6 years ago

Type: feature request / enhancement

Versions:

Description: a user requested help for tickets which were not processed. This happened because their client uses IR-01234567 as a format for their references. This obviously overlaps with iTop's default R-0123456 ticket referencing.

The idea is to implement a 'remove_patterns' field (multiline: one pattern per line). This would either be completely removed or bypassed when processing the mail title to check if there's a reference.

This would not help if another user used iTop with exactly the same settings though


The GetRelatedTicket method should become something like this

if ($oTicket === null)
{
    // No associated ticket found by parsing the headers, check
    // if the subject does not match a specific pattern
    $sPattern = $this->FixPattern($this->Get('title_pattern'));
    $sSubject = $oEmail->sSubject;

   // Now sanitize $sSubject here to exclude anything you want. You could use preg_replace to get rid of IR-<their amount of numbers if it doesn't change?>
   $sSubject = .... ;

    if(($sPattern != '') && (preg_match($sPattern, $sSubject, $aMatches)))
    {
        $iTicketId = 0;
        sscanf($aMatches[1], '%d', $iTicketId);
        $this->Trace("iTop Simple Email Synchro: Retrieving ticket ".$iTicketId." (match by subject pattern)...");
        $oTicket = MetaModel::GetObject('Ticket', $iTicketId, false);
    }
}
jbostoen commented 6 years ago

Implemented today.