Work on email collector
This commit is contained in:
parent
3cfeba0113
commit
f9860e1425
@ -554,10 +554,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>'.$ruleaction['actionparam'].'</td>';
|
print '<td>'.$ruleaction['actionparam'].'</td>';
|
||||||
print '<td class="right">';
|
// Move up/down
|
||||||
//print $ruleactionobj->getLibStatut(3);
|
|
||||||
print ' <a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deleteoperation&operationid='.$ruleaction['id'].'">'.img_delete().'</a>';
|
|
||||||
print '</td>';
|
|
||||||
print '<td class="center linecolmove tdlineupdown">';
|
print '<td class="center linecolmove tdlineupdown">';
|
||||||
if ($i > 0)
|
if ($i > 0)
|
||||||
{
|
{
|
||||||
@ -567,6 +564,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=down&rowid='.$ruleaction['id'].'">'.img_down('default', 0, 'imgdownforline').'</a>';
|
print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=down&rowid='.$ruleaction['id'].'">'.img_down('default', 0, 'imgdownforline').'</a>';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
// Delete
|
||||||
|
print '<td class="right">';
|
||||||
|
print ' <a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deleteoperation&operationid='.$ruleaction['id'].'">'.img_delete().'</a>';
|
||||||
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -575,6 +576,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
if (! empty($conf->use_javascript_ajax)) {
|
if (! empty($conf->use_javascript_ajax)) {
|
||||||
|
$urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id;
|
||||||
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
|
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,8 +77,8 @@ $(document).ready(function(){
|
|||||||
function() {
|
function() {
|
||||||
console.log("tableDND end of ajax call");
|
console.log("tableDND end of ajax call");
|
||||||
if (reloadpage == 1) {
|
if (reloadpage == 1) {
|
||||||
//console.log('<?php echo dol_escape_js($_SERVER['QUERY_STRING']); ?>');
|
//console.log('<?php echo $urltorefreshaftermove.' - '.$_SERVER['PHP_SELF'].' - '.dol_escape_js($_SERVER['QUERY_STRING']); ?>');
|
||||||
location.href = '<?php echo dol_escape_js($_SERVER['PHP_SELF']).'?'.dol_escape_js($_SERVER['QUERY_STRING']); ?>';
|
location.href = '<?php echo dol_escape_js(empty($urltorefreshaftermove) ? ($_SERVER['PHP_SELF'].'?'.dol_escape_js($_SERVER['QUERY_STRING'])) : $urltorefreshaftermove); ?>';
|
||||||
} else {
|
} else {
|
||||||
$("#<?php echo $tagidfortablednd; ?> .drag").each(
|
$("#<?php echo $tagidfortablednd; ?> .drag").each(
|
||||||
function( intIndex ) {
|
function( intIndex ) {
|
||||||
|
|||||||
@ -734,9 +734,10 @@ class EmailCollector extends CommonObject
|
|||||||
* @param string $actionparam Action parameters
|
* @param string $actionparam Action parameters
|
||||||
* @param string $messagetext Body
|
* @param string $messagetext Body
|
||||||
* @param string $subject Subject
|
* @param string $subject Subject
|
||||||
|
* @param string $header Header
|
||||||
* @return int 0=OK, Nb of error if error
|
* @return int 0=OK, Nb of error if error
|
||||||
*/
|
*/
|
||||||
private function overwritePropertiesOfObject(&$object, $actionparam, $messagetext, $subject)
|
private function overwritePropertiesOfObject(&$object, $actionparam, $messagetext, $subject, $header)
|
||||||
{
|
{
|
||||||
$errorforthisaction = 0;
|
$errorforthisaction = 0;
|
||||||
|
|
||||||
@ -776,21 +777,35 @@ class EmailCollector extends CommonObject
|
|||||||
$sourcefield=$regforregex[1];
|
$sourcefield=$regforregex[1];
|
||||||
$regexstring=$regforregex[2];
|
$regexstring=$regforregex[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($sourcefield) && ! empty($regexstring))
|
if (! empty($sourcefield) && ! empty($regexstring))
|
||||||
{
|
{
|
||||||
if (strtolower($sourcefield) == 'body') $sourcestring=$messagetext;
|
if (strtolower($sourcefield) == 'body') $sourcestring=$messagetext;
|
||||||
elseif (strtolower($sourcefield) == 'subject') $sourcestring=$subject;
|
elseif (strtolower($sourcefield) == 'subject') $sourcestring=$subject;
|
||||||
|
elseif (strtolower($sourcefield) == 'header') $sourcestring=$header;
|
||||||
|
|
||||||
$regforval=array();
|
if ($sourcestring)
|
||||||
if (preg_match('/'.preg_quote($regexstring, '/').'/', $sourcestring, $regforval))
|
|
||||||
{
|
{
|
||||||
// Overwrite param $tmpproperty
|
$regforval=array();
|
||||||
$object->$tmpproperty = $regforval[1];
|
//var_dump($regexstring);var_dump($sourcestring);
|
||||||
|
if (preg_match('/'.$regexstring.'/ms', $sourcestring, $regforval))
|
||||||
|
{
|
||||||
|
//var_dump($regforval[1]);exit;
|
||||||
|
// Overwrite param $tmpproperty
|
||||||
|
$object->$tmpproperty = isset($regforval[1])?trim($regforval[1]):null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Regex not found
|
||||||
|
$object->$tmpproperty = null;
|
||||||
|
}
|
||||||
|
//var_dump($object->$tmpproperty);exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Nothing can be done for this param
|
// Nothing can be done for this param
|
||||||
|
$errorforthisaction++;
|
||||||
|
$this->errors = 'The extract rule to use has on an unknown source (must be HEADER, SUBJECT or BODY)';
|
||||||
|
$this->errors[] = $this->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (preg_match('/^SET:(.*)$/', $valueforproperty, $reg))
|
elseif (preg_match('/^SET:(.*)$/', $valueforproperty, $reg))
|
||||||
@ -1360,7 +1375,7 @@ class EmailCollector extends CommonObject
|
|||||||
$thirdpartystatic->email = $from;
|
$thirdpartystatic->email = $from;
|
||||||
|
|
||||||
// Overwrite values with values extracted from source email
|
// Overwrite values with values extracted from source email
|
||||||
$errorforthisaction = $this->overwritePropertiesOfObject($thirdpartystatic, $operation['actionparam'], $messagetext, $subject);
|
$errorforthisaction = $this->overwritePropertiesOfObject($thirdpartystatic, $operation['actionparam'], $messagetext, $subject, $header);
|
||||||
|
|
||||||
if ($errorforthisaction)
|
if ($errorforthisaction)
|
||||||
{
|
{
|
||||||
@ -1441,7 +1456,7 @@ class EmailCollector extends CommonObject
|
|||||||
//$actioncomm->extraparams = $extraparams;
|
//$actioncomm->extraparams = $extraparams;
|
||||||
|
|
||||||
// Overwrite values with values extracted from source email
|
// Overwrite values with values extracted from source email
|
||||||
$errorforthisaction = $this->overwritePropertiesOfObject($actioncommn, $operation['actionparam'], $messagetext, $subject);
|
$errorforthisaction = $this->overwritePropertiesOfObject($actioncommn, $operation['actionparam'], $messagetext, $subject, $header);
|
||||||
|
|
||||||
if ($errorforthisaction)
|
if ($errorforthisaction)
|
||||||
{
|
{
|
||||||
@ -1513,7 +1528,7 @@ class EmailCollector extends CommonObject
|
|||||||
$projecttocreate->ref = $defaultref;
|
$projecttocreate->ref = $defaultref;
|
||||||
|
|
||||||
// Overwrite values with values extracted from source email
|
// Overwrite values with values extracted from source email
|
||||||
$errorforthisaction = $this->overwritePropertiesOfObject($projecttocreate, $operation['actionparam'], $messagetext, $subject);
|
$errorforthisaction = $this->overwritePropertiesOfObject($projecttocreate, $operation['actionparam'], $messagetext, $subject, $header);
|
||||||
|
|
||||||
if ($errorforthisaction)
|
if ($errorforthisaction)
|
||||||
{
|
{
|
||||||
@ -1597,7 +1612,7 @@ class EmailCollector extends CommonObject
|
|||||||
$tickettocreate->ref = $defaultref;
|
$tickettocreate->ref = $defaultref;
|
||||||
|
|
||||||
// Overwrite values with values extracted from source email
|
// Overwrite values with values extracted from source email
|
||||||
$errorforthisaction = $this->overwritePropertiesOfObject($tickettocreate, $operation['actionparam'], $messagetext, $subject);
|
$errorforthisaction = $this->overwritePropertiesOfObject($tickettocreate, $operation['actionparam'], $messagetext, $subject, $header);
|
||||||
|
|
||||||
if ($errorforthisaction)
|
if ($errorforthisaction)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1849,7 +1849,7 @@ WithoutDolTrackingID=Dolibarr Tracking ID not found
|
|||||||
FormatZip=Zip
|
FormatZip=Zip
|
||||||
MainMenuCode=Menu entry code (mainmenu)
|
MainMenuCode=Menu entry code (mainmenu)
|
||||||
ECMAutoTree=Show automatic ECM tree
|
ECMAutoTree=Show automatic ECM tree
|
||||||
OperationParamDesc=Define values to use for action, or how to extract values. For example:<br>objproperty1=SET:abc<br>objproperty2=EXTRACT:HEADER:X-Myheaderkey.*[^\s]+(.*)<br>objproperty3=EXTRACT:SUBJECT:([^\s]*)<br>object.objproperty4=EXTRACT:BODY:My company name is\s([^\s]*)<br><br>Use a ; char as separator to extract or set several properties.
|
OperationParamDesc=Define values to use for action, or how to extract values. For example:<br>objproperty1=SET:abc<br>objproperty2=EXTRACT:HEADER:X-Myheaderkey.*[^\s]+(.*)<br>options_myextrafield=EXTRACT:SUBJECT:([^\s]*)<br>object.objproperty4=EXTRACT:BODY:My company name is\s([^\s]*)<br><br>Use a ; char as separator to extract or set several properties.
|
||||||
OpeningHours=Opening hours
|
OpeningHours=Opening hours
|
||||||
OpeningHoursDesc=Enter here the regular opening hours of your company.
|
OpeningHoursDesc=Enter here the regular opening hours of your company.
|
||||||
ResourceSetup=Configuration of Resource module
|
ResourceSetup=Configuration of Resource module
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user