Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename settings (consistency) #9

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions classes/emailmessage.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ protected function PregReplaceCallback($aMatches)
/**
* When the message is a reply or forward of another message, this method
* (tries to) extract the "new" part of the body in HTML, producing some HTML
* as the output. The filtering is based on a list of tags/classes to remove (overrideable by 'html-tags-to-remove' in the config)
* as the output. The filtering is based on a list of tags/classes to remove (overrideable by 'html_tags_to_remove' in the config)
*/
public function GetNewPartHTML($sBodyText = null)
{
Expand All @@ -242,7 +242,7 @@ public function GetNewPartHTML($sBodyText = null)

if (class_exists('MetaModel'))
{
$aTagsToRemove = MetaModel::GetModuleSetting('combodo-email-synchro', 'html-tags-to-remove', $aTagsToRemove);
$aTagsToRemove = MetaModel::GetModuleSetting('combodo-email-synchro', 'html_tags_to_remove', $aTagsToRemove);
}

$this->oDoc = new DOMDocument();
Expand Down Expand Up @@ -366,9 +366,9 @@ public function GetNewPart($sBodyText = null, $sBodyFormat = null)

if (class_exists('MetaModel'))
{
$aIntroductoryPatterns = MetaModel::GetModuleSetting('combodo-email-synchro', 'introductory-patterns', $aIntroductoryPatterns);
$aGlobalDelimiterPatterns = MetaModel::GetModuleSetting('combodo-email-synchro', 'multiline-delimiter-patterns', $aGlobalDelimiterPatterns);
$aDelimiterPatterns = MetaModel::GetModuleSetting('combodo-email-synchro', 'delimiter-patterns', $aDelimiterPatterns);
$aIntroductoryPatterns = MetaModel::GetModuleSetting('combodo-email-synchro', 'introductory_patterns', $aIntroductoryPatterns);
$aGlobalDelimiterPatterns = MetaModel::GetModuleSetting('combodo-email-synchro', 'multiline_delimiter_patterns', $aGlobalDelimiterPatterns);
$aDelimiterPatterns = MetaModel::GetModuleSetting('combodo-email-synchro', 'delimiter_patterns', $aDelimiterPatterns);
}

if ($sBodyFormat == 'text/html')
Expand Down
60 changes: 56 additions & 4 deletions module.combodo-email-synchro.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@
'maximum_email_size' => '10M', // Maximum allowed size for incoming emails
'big_files_dir' => '',
'exclude_attachment_types' => array('application/exe'), // Example: 'application/exe', 'application/x-winexe', 'application/msdos-windows'
// Default tags to remove: array of tag_name => array of class names
'html_tags_to_remove' => array(
'blockquote' => array(),
'div' => array('gmail_quote', 'moz-cite-prefix'),
'pre' => array('moz-signature')
),
// Lines to be removed just above the 'new part' in a reply-to message... add your own patterns below
'introductory-patterns' => array(
'introductory_patterns' => array(
'/^De : .+$/', // Outlook French
'/^le .+ a écrit :$/i', // Thunderbird French
'/^on .+ wrote:$/i', // Thunderbird English
'|^[0-9]{4}/[0-9]{1,2}/[0-9]{1,2} .+:$|', // Gmail style
Expand All @@ -48,13 +55,16 @@
// The "new" part of the message is the text before the pattern
// Add your own multi-line patterns (use \\R for a line break)
// These patterns depend on the mail client/server used... feel free to add your own discoveries to the list
'multiline-delimiter-patterns' => array(
'multiline_delimiter_patterns' => array(
'/\\RFrom: .+\\RSent: .+\\R/m', // Outlook English
'/\\R_+\\R/m', // A whole line made only of underscore characters
'/\\RDe : .+\\R\\R?Envoyé : /m', // Outlook French, HTML and rich text
'/\\RDe : .+\\RDate d\'envoi : .+\\R/m', // Outlook French, plain text
'/\\R-----Message d\'origine-----\\R/m',
),
'delimiter_patterns' => array(
'/^>.*$/' => false, // Old fashioned mail clients: continue processing the lines, each of them is preceded by >
),
'use_message_id_as_uid' => false, // Do NOT change this unless you known what you are doing!!
'images_minimum_size' => '100x20', // Images smaller that these dimensions will be ignored (signatures...)
'images_maximum_size' => '', // Images bigger that these dimensions will be resized before uploading into iTop
Expand Down Expand Up @@ -102,8 +112,6 @@ public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousV
$oMailboxAttDef = MetaModel::GetAttributeDef('EmailReplica', 'mailbox_path');
$sMailboxColName = $oMailboxAttDef->Get('sql');

$sFrienlynameAttCode = MetaModel::GetFriendlyNameAttributeCode('EmailReplica');

// Looping on inboxes to update
$oSet = new DBObjectSet($oSearch);
while ($oInbox = $oSet->Fetch())
Expand All @@ -113,6 +121,50 @@ public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousV
$iRet = CMDBSource::Query($sUpdateQuery); // Throws an exception in case of error
SetupPage::log_info("Updated $iRet rows.");
}

// Workaround for BeforeWritingConfig() not having $sPreviousVersion
if($sPreviousVersion != '' && version_compare($sPreviousVersion, '3.3.1', '<=')) {

// In previous versions, these parameters were not named in a consistent way. Rename.
$aSettings = array(
'html_tags_to_remove',
'introductory_patterns',
'multiline_delimiter_patterns',
'delimiter_patterns'
);

$sTargetEnvironment = 'production';
$sConfigFile = APPCONF.$sTargetEnvironment.'/'.ITOP_CONFIG_FILE;
$oExistingConfig = new Config($sConfigFile);

foreach($aSettings as $sSetting) {

$aDeprecatedSettingValue = $oExistingConfig->GetModuleSetting('combodo-email-synchro', str_replace('_', '-', $sSetting), null);
if($aDeprecatedSettingValue !== null) {
$oExistingConfig->SetModuleSetting('combodo-email-synchro', $sSetting, $aDeprecatedSettingValue);
}

}

// Update existing configuration PRIOR to iTop installation actually processing this.
$oExistingConfig->WriteToFile();

}

}

/**
* Handler called before the creation/update of the database schema
*
* @param $oConfiguration Config The new configuration of the application
*
* @returns \Config $oConfiguration The new configuration of the application
*
*/
public static function BeforeWritingConfig(Config $oConfiguration)
{

return $oConfiguration;
}

}
Expand Down