Fix search on not with imapv2
This commit is contained in:
parent
0d8d2528b0
commit
949e288ce0
@ -440,15 +440,15 @@ class EmailCollector extends CommonObject
|
|||||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public function fetchLines()
|
public function fetchLines()
|
||||||
{
|
{
|
||||||
$this->lines=array();
|
$this->lines=array();
|
||||||
|
|
||||||
// Load lines with object EmailCollectorLine
|
// Load lines with object EmailCollectorLine
|
||||||
|
|
||||||
return count($this->lines)?1:0;
|
return count($this->lines)?1:0;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all account and load objects into an array
|
* Fetch all account and load objects into an array
|
||||||
@ -1096,6 +1096,8 @@ class EmailCollector extends CommonObject
|
|||||||
$searchfilterisanswer = 0;
|
$searchfilterisanswer = 0;
|
||||||
$searchfilterisnotanswer = 0;
|
$searchfilterisnotanswer = 0;
|
||||||
$searchfilterreplyto = 0;
|
$searchfilterreplyto = 0;
|
||||||
|
$searchfilterexcludebody = '';
|
||||||
|
$searchfilterexcludesubject = '';
|
||||||
$operationslog = '';
|
$operationslog = '';
|
||||||
|
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
@ -1154,7 +1156,7 @@ class EmailCollector extends CommonObject
|
|||||||
getDolGlobalString('OAUTH_'.$this->oauth_service.'_ID'),
|
getDolGlobalString('OAUTH_'.$this->oauth_service.'_ID'),
|
||||||
getDolGlobalString('OAUTH_'.$this->oauth_service.'_SECRET'),
|
getDolGlobalString('OAUTH_'.$this->oauth_service.'_SECRET'),
|
||||||
getDolGlobalString('OAUTH_'.$this->oauth_service.'_URLAUTHORIZE')
|
getDolGlobalString('OAUTH_'.$this->oauth_service.'_URLAUTHORIZE')
|
||||||
);
|
);
|
||||||
$serviceFactory = new \OAuth\ServiceFactory();
|
$serviceFactory = new \OAuth\ServiceFactory();
|
||||||
$oauthname = explode('-', $OAUTH_SERVICENAME);
|
$oauthname = explode('-', $OAUTH_SERVICENAME);
|
||||||
// ex service is Google-Emails we need only the first part Google
|
// ex service is Google-Emails we need only the first part Google
|
||||||
@ -1285,10 +1287,20 @@ class EmailCollector extends CommonObject
|
|||||||
array_push($criteria, array($not."CC" => $rule['rulevalue']));
|
array_push($criteria, array($not."CC" => $rule['rulevalue']));
|
||||||
}
|
}
|
||||||
if ($rule['type'] == 'subject') {
|
if ($rule['type'] == 'subject') {
|
||||||
array_push($criteria, array($not."SUBJECT" => $rule['rulevalue']));
|
if (strpos($rule['rulevalue'], '!') === 0) {
|
||||||
|
//array_push($criteria, array("NOT SUBJECT" => $rule['rulevalue']));
|
||||||
|
$searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']);
|
||||||
|
} else {
|
||||||
|
array_push($criteria, array("SUBJECT" => $rule['rulevalue']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($rule['type'] == 'body') {
|
if ($rule['type'] == 'body') {
|
||||||
array_push($criteria, array($not."BODY" => $rule['rulevalue']));
|
if (strpos($rule['rulevalue'], '!') === 0) {
|
||||||
|
//array_push($criteria, array("NOT BODY" => $rule['rulevalue']));
|
||||||
|
$searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']);
|
||||||
|
} else {
|
||||||
|
array_push($criteria, array("BODY" => $rule['rulevalue']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($rule['type'] == 'header') {
|
if ($rule['type'] == 'header') {
|
||||||
array_push($criteria, array($not."HEADER" => $rule['rulevalue']));
|
array_push($criteria, array($not."HEADER" => $rule['rulevalue']));
|
||||||
@ -1296,12 +1308,12 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
/* seems not used */
|
/* seems not used */
|
||||||
/*
|
/*
|
||||||
if ($rule['type'] == 'notinsubject') {
|
if ($rule['type'] == 'notinsubject') {
|
||||||
array_push($criteria, array($not."SUBJECT NOT" => $rule['rulevalue']));
|
array_push($criteria, array($not."SUBJECT NOT" => $rule['rulevalue']));
|
||||||
}
|
}
|
||||||
if ($rule['type'] == 'notinbody') {
|
if ($rule['type'] == 'notinbody') {
|
||||||
array_push($criteria, array($not."BODY NOT" => $rule['rulevalue']));
|
array_push($criteria, array($not."BODY NOT" => $rule['rulevalue']));
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if ($rule['type'] == 'seen') {
|
if ($rule['type'] == 'seen') {
|
||||||
array_push($criteria, array($not."SEEN"));
|
array_push($criteria, array($not."SEEN"));
|
||||||
@ -1406,10 +1418,20 @@ class EmailCollector extends CommonObject
|
|||||||
$search .= ($search ? ' ' : '').$not.'CC';
|
$search .= ($search ? ' ' : '').$not.'CC';
|
||||||
}
|
}
|
||||||
if ($rule['type'] == 'subject') {
|
if ($rule['type'] == 'subject') {
|
||||||
$search .= ($search ? ' ' : '').$not.'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"';
|
if (strpos($rule['rulevalue'], '!') === 0) {
|
||||||
|
//$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
|
||||||
|
$searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']);
|
||||||
|
} else {
|
||||||
|
$search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($rule['type'] == 'body') {
|
if ($rule['type'] == 'body') {
|
||||||
$search .= ($search ? ' ' : '').$not.'BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
|
if (strpos($rule['rulevalue'], '!') === 0) {
|
||||||
|
//$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
|
||||||
|
$searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']);
|
||||||
|
} else {
|
||||||
|
$search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($rule['type'] == 'header') {
|
if ($rule['type'] == 'header') {
|
||||||
$search .= ($search ? ' ' : '').$not.'HEADER '.$rule['rulevalue'];
|
$search .= ($search ? ' ' : '').$not.'HEADER '.$rule['rulevalue'];
|
||||||
@ -1417,12 +1439,12 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
/* seems not used */
|
/* seems not used */
|
||||||
/*
|
/*
|
||||||
if ($rule['type'] == 'notinsubject') {
|
if ($rule['type'] == 'notinsubject') {
|
||||||
$search .= ($search ? ' ' : '').'NOT SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"';
|
$search .= ($search ? ' ' : '').'NOT SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"';
|
||||||
}
|
}
|
||||||
if ($rule['type'] == 'notinbody') {
|
if ($rule['type'] == 'notinbody') {
|
||||||
$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
|
$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if ($rule['type'] == 'seen') {
|
if ($rule['type'] == 'seen') {
|
||||||
$search .= ($search ? ' ' : '').$not.'SEEN';
|
$search .= ($search ? ' ' : '').$not.'SEEN';
|
||||||
@ -1538,19 +1560,19 @@ class EmailCollector extends CommonObject
|
|||||||
if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) {
|
if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) {
|
||||||
// Loop to get part html and plain
|
// Loop to get part html and plain
|
||||||
/*
|
/*
|
||||||
0 multipart/mixed
|
0 multipart/mixed
|
||||||
1 multipart/alternative
|
1 multipart/alternative
|
||||||
1.1 text/plain
|
1.1 text/plain
|
||||||
1.2 text/html
|
1.2 text/html
|
||||||
2 message/rfc822
|
2 message/rfc822
|
||||||
2 multipart/mixed
|
2 multipart/mixed
|
||||||
2.1 multipart/alternative
|
2.1 multipart/alternative
|
||||||
2.1.1 text/plain
|
2.1.1 text/plain
|
||||||
2.1.2 text/html
|
2.1.2 text/html
|
||||||
2.2 message/rfc822
|
2.2 message/rfc822
|
||||||
2.2 multipart/alternative
|
2.2 multipart/alternative
|
||||||
2.2.1 text/plain
|
2.2.1 text/plain
|
||||||
2.2.2 text/html
|
2.2.2 text/html
|
||||||
*/
|
*/
|
||||||
dol_syslog("Start of loop on email", LOG_INFO, 1);
|
dol_syslog("Start of loop on email", LOG_INFO, 1);
|
||||||
|
|
||||||
@ -1684,8 +1706,6 @@ class EmailCollector extends CommonObject
|
|||||||
$ticketfoundby = '';
|
$ticketfoundby = '';
|
||||||
$candidaturefoundby = '';
|
$candidaturefoundby = '';
|
||||||
|
|
||||||
$this->db->begin();
|
|
||||||
|
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
|
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
|
||||||
dol_syslog("msgid=".$overview['message_id']." date=".dol_print_date($overview['date'], 'dayrfc', 'gmt')." from=".$overview['from']." to=".$overview['to']." subject=".$overview['subject']);
|
dol_syslog("msgid=".$overview['message_id']." date=".dol_print_date($overview['date'], 'dayrfc', 'gmt')." from=".$overview['from']." to=".$overview['to']." subject=".$overview['subject']);
|
||||||
@ -1719,7 +1739,7 @@ class EmailCollector extends CommonObject
|
|||||||
$attachments = [];
|
$attachments = [];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->getmsg($connection, $imapemail);
|
$this->getmsg($connection, $imapemail); // This set global var $charset, $htmlmsg, $plainmsg, $attachments
|
||||||
}
|
}
|
||||||
//print $plainmsg;
|
//print $plainmsg;
|
||||||
//var_dump($plainmsg); exit;
|
//var_dump($plainmsg); exit;
|
||||||
@ -1729,6 +1749,15 @@ class EmailCollector extends CommonObject
|
|||||||
// Removed emojis
|
// Removed emojis
|
||||||
$messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext);
|
$messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext);
|
||||||
|
|
||||||
|
if ($searchfilterexcludebody) {
|
||||||
|
if (preg_match('/'.preg_quote($searchfilterexcludebody, '/').'/ms', $messagetext)) {
|
||||||
|
$nbemailprocessed++;
|
||||||
|
$operationslog .= '<br>Discarded - Email body contains string '.$searchfilterexcludebody;
|
||||||
|
dol_syslog(" Discarded - Email body contains string ".$searchfilterexcludebody);
|
||||||
|
continue; // Exclude email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//var_dump($plainmsg);
|
//var_dump($plainmsg);
|
||||||
//var_dump($htmlmsg);
|
//var_dump($htmlmsg);
|
||||||
//var_dump($messagetext);
|
//var_dump($messagetext);
|
||||||
@ -1738,45 +1767,45 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
// Parse IMAP email structure
|
// Parse IMAP email structure
|
||||||
/*
|
/*
|
||||||
$structure = imap_fetchstructure($connection, $imapemail, 0);
|
$structure = imap_fetchstructure($connection, $imapemail, 0);
|
||||||
|
|
||||||
$partplain = $parthtml = -1;
|
$partplain = $parthtml = -1;
|
||||||
$encodingplain = $encodinghtml = '';
|
$encodingplain = $encodinghtml = '';
|
||||||
|
|
||||||
$result = createPartArray($structure, '');
|
$result = createPartArray($structure, '');
|
||||||
|
|
||||||
foreach($result as $part)
|
foreach($result as $part)
|
||||||
{
|
{
|
||||||
// $part['part_object']->type seems 0 for content
|
// $part['part_object']->type seems 0 for content
|
||||||
// $part['part_object']->type seems 5 for attachment
|
// $part['part_object']->type seems 5 for attachment
|
||||||
if (empty($part['part_object'])) continue;
|
if (empty($part['part_object'])) continue;
|
||||||
if ($part['part_object']->subtype == 'HTML')
|
if ($part['part_object']->subtype == 'HTML')
|
||||||
{
|
{
|
||||||
$parthtml=$part['part_number'];
|
$parthtml=$part['part_number'];
|
||||||
if ($part['part_object']->encoding == 4)
|
if ($part['part_object']->encoding == 4)
|
||||||
{
|
{
|
||||||
$encodinghtml = 'aaa';
|
$encodinghtml = 'aaa';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($part['part_object']->subtype == 'PLAIN')
|
if ($part['part_object']->subtype == 'PLAIN')
|
||||||
{
|
{
|
||||||
$partplain=$part['part_number'];
|
$partplain=$part['part_number'];
|
||||||
if ($part['part_object']->encoding == 4)
|
if ($part['part_object']->encoding == 4)
|
||||||
{
|
{
|
||||||
$encodingplain = 'rr';
|
$encodingplain = 'rr';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//var_dump($result);
|
//var_dump($result);
|
||||||
//var_dump($partplain);
|
//var_dump($partplain);
|
||||||
//var_dump($parthtml);
|
//var_dump($parthtml);
|
||||||
|
|
||||||
//var_dump($structure);
|
//var_dump($structure);
|
||||||
//var_dump($parthtml);
|
//var_dump($parthtml);
|
||||||
//var_dump($partplain);
|
//var_dump($partplain);
|
||||||
|
|
||||||
$messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK);
|
$messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//var_dump($messagetext);
|
//var_dump($messagetext);
|
||||||
//var_dump($structure->parts[0]->parts);
|
//var_dump($structure->parts[0]->parts);
|
||||||
@ -1812,6 +1841,14 @@ class EmailCollector extends CommonObject
|
|||||||
//var_dump($msgid);exit;
|
//var_dump($msgid);exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($searchfilterexcludesubject) {
|
||||||
|
if (preg_match('/'.preg_quote($searchfilterexcludesubject, '/').'/ms', $subject)) {
|
||||||
|
$nbemailprocessed++;
|
||||||
|
$operationslog .= '<br>Discarded - Email subject contains string '.$searchfilterexcludesubject;
|
||||||
|
dol_syslog(" Discarded - Email subject contains string ".$searchfilterexcludesubject);
|
||||||
|
continue; // Exclude email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$reg = array();
|
$reg = array();
|
||||||
if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) {
|
if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) {
|
||||||
@ -1830,6 +1867,7 @@ class EmailCollector extends CommonObject
|
|||||||
}
|
}
|
||||||
$fk_element_id = 0; $fk_element_type = '';
|
$fk_element_id = 0; $fk_element_type = '';
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
$contactid = 0; $thirdpartyid = 0; $projectid = 0; $ticketid = 0;
|
$contactid = 0; $thirdpartyid = 0; $projectid = 0; $ticketid = 0;
|
||||||
|
|
||||||
@ -1918,11 +1956,11 @@ class EmailCollector extends CommonObject
|
|||||||
$objectemail = new Adherent($this->db);
|
$objectemail = new Adherent($this->db);
|
||||||
}
|
}
|
||||||
/*if ($reg[1] == 'leav') { // Leave / Holiday
|
/*if ($reg[1] == 'leav') { // Leave / Holiday
|
||||||
$objectemail = new Holiday($db);
|
$objectemail = new Holiday($db);
|
||||||
}
|
}
|
||||||
if ($reg[1] == 'exp') { // ExpenseReport
|
if ($reg[1] == 'exp') { // ExpenseReport
|
||||||
$objectemail = new ExpenseReport($db);
|
$objectemail = new ExpenseReport($db);
|
||||||
}*/
|
}*/
|
||||||
} elseif (preg_match('/<(.*@.*)>/', $reference, $reg)) {
|
} elseif (preg_match('/<(.*@.*)>/', $reference, $reg)) {
|
||||||
// This is an external reference, we check if we have it in our database
|
// This is an external reference, we check if we have it in our database
|
||||||
if (!is_object($objectemail)) {
|
if (!is_object($objectemail)) {
|
||||||
@ -2081,34 +2119,34 @@ class EmailCollector extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if ($replyto) {
|
if ($replyto) {
|
||||||
if (empty($contactid)) { // Try to find contact using email
|
if (empty($contactid)) { // Try to find contact using email
|
||||||
$result = $contactstatic->fetch(0, null, '', $replyto);
|
$result = $contactstatic->fetch(0, null, '', $replyto);
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
dol_syslog("We found a contact with the email ".$replyto);
|
dol_syslog("We found a contact with the email ".$replyto);
|
||||||
$contactid = $contactstatic->id;
|
$contactid = $contactstatic->id;
|
||||||
$contactfoundby = 'email of contact ('.$replyto.')';
|
$contactfoundby = 'email of contact ('.$replyto.')';
|
||||||
if (empty($thirdpartyid) && $contactstatic->socid > 0) {
|
if (empty($thirdpartyid) && $contactstatic->socid > 0) {
|
||||||
$result = $thirdpartystatic->fetch($contactstatic->socid);
|
$result = $thirdpartystatic->fetch($contactstatic->socid);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$thirdpartyid = $thirdpartystatic->id;
|
$thirdpartyid = $thirdpartystatic->id;
|
||||||
$thirdpartyfoundby = 'email of contact ('.$replyto.')';
|
$thirdpartyfoundby = 'email of contact ('.$replyto.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($thirdpartyid)) { // Try to find thirdparty using email
|
if (empty($thirdpartyid)) { // Try to find thirdparty using email
|
||||||
$result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto);
|
$result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
dol_syslog("We found a thirdparty with the email ".$replyto);
|
dol_syslog("We found a thirdparty with the email ".$replyto);
|
||||||
$thirdpartyid = $thirdpartystatic->id;;
|
$thirdpartyid = $thirdpartystatic->id;;
|
||||||
$thirdpartyfoundby = 'email ('.$replyto.')';
|
$thirdpartyfoundby = 'email ('.$replyto.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Do operations (extract variables and creating data)
|
// Do operations (extract variables and creating data)
|
||||||
if ($mode < 2) { // 0=Mode production, 1=Mode test (read IMAP and try SQL update then rollback), 2=Mode test with no SQL updates
|
if ($mode < 2) { // 0=Mode production, 1=Mode test (read IMAP and try SQL update then rollback), 2=Mode test with no SQL updates
|
||||||
@ -2549,98 +2587,98 @@ class EmailCollector extends CommonObject
|
|||||||
$this->errors[] = 'User Not allowed to add documents';
|
$this->errors[] = 'User Not allowed to add documents';
|
||||||
}
|
}
|
||||||
$arrayobject = array(
|
$arrayobject = array(
|
||||||
'propale' => array('table' => 'propal',
|
'propale' => array('table' => 'propal',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'comm/propal/class/propal.class.php',
|
'class' => 'comm/propal/class/propal.class.php',
|
||||||
'object' => 'Propal'),
|
'object' => 'Propal'),
|
||||||
'holiday' => array('table' => 'holiday',
|
'holiday' => array('table' => 'holiday',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'holiday/class/holiday.class.php',
|
'class' => 'holiday/class/holiday.class.php',
|
||||||
'object' => 'Holiday'),
|
'object' => 'Holiday'),
|
||||||
'expensereport' => array('table' => 'expensereport',
|
'expensereport' => array('table' => 'expensereport',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'expensereport/class/expensereport.class.php',
|
'class' => 'expensereport/class/expensereport.class.php',
|
||||||
'object' => 'ExpenseReport'),
|
'object' => 'ExpenseReport'),
|
||||||
'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition',
|
'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'recruitment/class/recruitmentjobposition.class.php',
|
'class' => 'recruitment/class/recruitmentjobposition.class.php',
|
||||||
'object' => 'RecruitmentJobPosition'),
|
'object' => 'RecruitmentJobPosition'),
|
||||||
'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature',
|
'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'recruitment/class/recruitmentcandidature.class.php',
|
'class' => 'recruitment/class/recruitmentcandidature.class.php',
|
||||||
'object' => ' RecruitmentCandidature'),
|
'object' => ' RecruitmentCandidature'),
|
||||||
'societe' => array('table' => 'societe',
|
'societe' => array('table' => 'societe',
|
||||||
'fields' => array('code_client', 'code_fournisseur'),
|
'fields' => array('code_client', 'code_fournisseur'),
|
||||||
'class' => 'societe/class/societe.class.php',
|
'class' => 'societe/class/societe.class.php',
|
||||||
'object' => 'Societe'),
|
'object' => 'Societe'),
|
||||||
'commande' => array('table' => 'commande',
|
'commande' => array('table' => 'commande',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'commande/class/commande.class.php',
|
'class' => 'commande/class/commande.class.php',
|
||||||
'object' => 'Commande'),
|
'object' => 'Commande'),
|
||||||
'expedition' => array('table' => 'expedition',
|
'expedition' => array('table' => 'expedition',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'expedition/class/expedition.class.php',
|
'class' => 'expedition/class/expedition.class.php',
|
||||||
'object' => 'Expedition'),
|
'object' => 'Expedition'),
|
||||||
'contract' => array('table' => 'contrat',
|
'contract' => array('table' => 'contrat',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'contrat/class/contrat.class.php',
|
'class' => 'contrat/class/contrat.class.php',
|
||||||
'object' => 'Contrat'),
|
'object' => 'Contrat'),
|
||||||
'fichinter' => array('table' => 'fichinter',
|
'fichinter' => array('table' => 'fichinter',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'fichinter/class/fichinter.class.php',
|
'class' => 'fichinter/class/fichinter.class.php',
|
||||||
'object' => 'Fichinter'),
|
'object' => 'Fichinter'),
|
||||||
'ticket' => array('table' => 'ticket',
|
'ticket' => array('table' => 'ticket',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'ticket/class/ticket.class.php',
|
'class' => 'ticket/class/ticket.class.php',
|
||||||
'object' => 'Ticket'),
|
'object' => 'Ticket'),
|
||||||
'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord',
|
'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'knowledgemanagement/class/knowledgemanagement.class.php',
|
'class' => 'knowledgemanagement/class/knowledgemanagement.class.php',
|
||||||
'object' => 'KnowledgeRecord'),
|
'object' => 'KnowledgeRecord'),
|
||||||
'supplier_proposal' => array('table' => 'supplier_proposal',
|
'supplier_proposal' => array('table' => 'supplier_proposal',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'supplier_proposal/class/supplier_proposal.class.php',
|
'class' => 'supplier_proposal/class/supplier_proposal.class.php',
|
||||||
'object' => 'SupplierProposal'),
|
'object' => 'SupplierProposal'),
|
||||||
'fournisseur/commande' => array('table' => 'commande_fournisseur',
|
'fournisseur/commande' => array('table' => 'commande_fournisseur',
|
||||||
'fields' => array('ref', 'ref_supplier'),
|
'fields' => array('ref', 'ref_supplier'),
|
||||||
'class' => 'fourn/class/fournisseur.commande.class.php',
|
'class' => 'fourn/class/fournisseur.commande.class.php',
|
||||||
'object' => 'SupplierProposal'),
|
'object' => 'SupplierProposal'),
|
||||||
'facture' => array('table' => 'facture',
|
'facture' => array('table' => 'facture',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'compta/facture/class/facture.class.php',
|
'class' => 'compta/facture/class/facture.class.php',
|
||||||
'object' => 'Facture'),
|
'object' => 'Facture'),
|
||||||
'fournisseur/facture' => array('table' => 'facture_fourn',
|
'fournisseur/facture' => array('table' => 'facture_fourn',
|
||||||
'fields' => array('ref', 'ref_client'),
|
'fields' => array('ref', 'ref_client'),
|
||||||
'class' => 'fourn/class/fournisseur.facture.class.php',
|
'class' => 'fourn/class/fournisseur.facture.class.php',
|
||||||
'object' => 'FactureFournisseur'),
|
'object' => 'FactureFournisseur'),
|
||||||
'produit' => array('table' => 'product',
|
'produit' => array('table' => 'product',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'product/class/product.class.php',
|
'class' => 'product/class/product.class.php',
|
||||||
'object' => 'Product'),
|
'object' => 'Product'),
|
||||||
'productlot' => array('table' => 'product_lot',
|
'productlot' => array('table' => 'product_lot',
|
||||||
'fields' => array('batch'),
|
'fields' => array('batch'),
|
||||||
'class' => 'product/stock/class/productlot.class.php',
|
'class' => 'product/stock/class/productlot.class.php',
|
||||||
'object' => 'Productlot'),
|
'object' => 'Productlot'),
|
||||||
'projet' => array('table' => 'projet',
|
'projet' => array('table' => 'projet',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'projet/class/projet.class.php',
|
'class' => 'projet/class/projet.class.php',
|
||||||
'object' => 'Project'),
|
'object' => 'Project'),
|
||||||
'projet_task' => array('table' => 'projet_task',
|
'projet_task' => array('table' => 'projet_task',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'projet/class/task.class.php',
|
'class' => 'projet/class/task.class.php',
|
||||||
'object' => 'Task'),
|
'object' => 'Task'),
|
||||||
'ressource' => array('table' => 'resource',
|
'ressource' => array('table' => 'resource',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'ressource/class/dolressource.class.php',
|
'class' => 'ressource/class/dolressource.class.php',
|
||||||
'object' => 'Dolresource'),
|
'object' => 'Dolresource'),
|
||||||
'bom' => array('table' => 'bom_bom',
|
'bom' => array('table' => 'bom_bom',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'bom/class/bom.class.php',
|
'class' => 'bom/class/bom.class.php',
|
||||||
'object' => 'BOM'),
|
'object' => 'BOM'),
|
||||||
'mrp' => array('table' => 'mrp_mo',
|
'mrp' => array('table' => 'mrp_mo',
|
||||||
'fields' => array('ref'),
|
'fields' => array('ref'),
|
||||||
'class' => 'mrp/class/mo.class.php',
|
'class' => 'mrp/class/mo.class.php',
|
||||||
'object' => 'Mo'),
|
'object' => 'Mo'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!is_object($hookmanager)) {
|
if (!is_object($hookmanager)) {
|
||||||
@ -2997,43 +3035,43 @@ class EmailCollector extends CommonObject
|
|||||||
|
|
||||||
// Set candidature ref if not yet defined
|
// Set candidature ref if not yet defined
|
||||||
/*if (empty($candidaturetocreate->ref)) We do not need this because we create object in draft status
|
/*if (empty($candidaturetocreate->ref)) We do not need this because we create object in draft status
|
||||||
{
|
{
|
||||||
// Get next Ref
|
// Get next Ref
|
||||||
$defaultref = '';
|
$defaultref = '';
|
||||||
$modele = empty($conf->global->CANDIDATURE_ADDON) ? 'mod_candidature_simple' : $conf->global->CANDIDATURE_ADDON;
|
$modele = empty($conf->global->CANDIDATURE_ADDON) ? 'mod_candidature_simple' : $conf->global->CANDIDATURE_ADDON;
|
||||||
|
|
||||||
// Search template files
|
// Search template files
|
||||||
$file = ''; $classname = ''; $filefound = 0; $reldir = '';
|
$file = ''; $classname = ''; $filefound = 0; $reldir = '';
|
||||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir)
|
||||||
{
|
{
|
||||||
$file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0);
|
$file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0);
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
$filefound = 1;
|
$filefound = 1;
|
||||||
$classname = $modele;
|
$classname = $modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filefound) {
|
if ($filefound) {
|
||||||
if ($savesocid > 0) {
|
if ($savesocid > 0) {
|
||||||
if ($savesocid != $candidaturetocreate->socid) {
|
if ($savesocid != $candidaturetocreate->socid) {
|
||||||
$errorforactions++;
|
$errorforactions++;
|
||||||
setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$candidaturetocreate->socid.') by setting socid in operation with a different value', null, 'errors');
|
setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$candidaturetocreate->socid.') by setting socid in operation with a different value', null, 'errors');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($candidaturetocreate->socid > 0)
|
if ($candidaturetocreate->socid > 0)
|
||||||
{
|
{
|
||||||
$thirdpartystatic->fetch($candidaturetocreate->socid);
|
$thirdpartystatic->fetch($candidaturetocreate->socid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php');
|
$result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php');
|
||||||
$modModuleToUseForNextValue = new $classname;
|
$modModuleToUseForNextValue = new $classname;
|
||||||
$defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate);
|
$defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate);
|
||||||
}
|
}
|
||||||
$candidaturetocreate->ref = $defaultref;
|
$candidaturetocreate->ref = $defaultref;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if ($errorforthisaction) {
|
if ($errorforthisaction) {
|
||||||
$errorforactions++;
|
$errorforactions++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user