diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php
index 68bec8431a7..a0e741a290f 100644
--- a/htdocs/admin/modules.php
+++ b/htdocs/admin/modules.php
@@ -231,7 +231,7 @@ if ($action == 'install') {
if (!$error) {
@dol_delete_dir_recursive($dirins.'/'.$modulenameval); // delete the target directory
$submodulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulenameval;
- if (!dol_is_dir($modulenamedir)) {
+ if (!dol_is_dir($submodulenamedir)) {
$submodulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval;
}
dol_syslog("We copy now directory ".$submodulenamedir." into target dir ".$dirins.'/'.$modulenameval);
@@ -476,7 +476,7 @@ foreach ($modulesdir as $dir) {
dol_syslog("Module ".get_class($objMod)." not qualified");
}
} else {
- print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
";
+ print "admin/modules.php Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
";
}
} catch (Exception $e) {
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php
index aaac40a525f..8a81d9a80e5 100644
--- a/htdocs/core/lib/oauth.lib.php
+++ b/htdocs/core/lib/oauth.lib.php
@@ -32,7 +32,7 @@ if (isModEnabled('stripe')) {
$supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array('callbackfile' => 'stripelive', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeLive', 'urlforcredentials'=>'', 'availablescopes'=>'read_write', 'returnurl'=>'/core/modules/oauth/stripelive_oauthcallback.php');
}
$supportedoauth2array['OAUTH_GITHUB_NAME'] = array('callbackfile' => 'github', 'picto' => 'github', 'urlforapp' => 'OAUTH_GITHUB_DESC', 'name'=>'GitHub', 'urlforcredentials'=>'https://github.com/settings/developers', 'availablescopes'=>'user,public_repo', 'returnurl'=>'/core/modules/oauth/github_oauthcallback.php');
-$supportedoauth2array['OAUTH_MICROSOFT_NAME'] = array('callbackfile' => 'microsoft', 'picto' => 'microsoft', 'urlforapp' => 'OAUTH_MICROSOFT_DESC', 'name'=>'Microsoft', 'urlforcredentials'=>'https://portal.azure.com/', 'availablescopes'=>'openid,offline_access,profile,email,User.Read,https://outlook.office.com/IMAP.AccessAsUser.All,https://outlook.office.com/SMTP.Send', 'returnurl'=>'/core/modules/oauth/microsoft_oauthcallback.php');
+$supportedoauth2array['OAUTH_MICROSOFT_NAME'] = array('callbackfile' => 'microsoft', 'picto' => 'microsoft', 'urlforapp' => 'OAUTH_MICROSOFT_DESC', 'name'=>'Microsoft', 'urlforcredentials'=>'https://portal.azure.com/', 'availablescopes'=>'openid,offline_access,profile,email,User.Read,https://outlook.office365.com/IMAP.AccessAsUser.All,https://outlook.office365.com/SMTP.Send', 'returnurl'=>'/core/modules/oauth/microsoft_oauthcallback.php');
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
$supportedoauth2array['OAUTH_OTHER_NAME'] = array('callbackfile' => 'generic', 'picto' => 'generic', 'urlforapp' => 'OAUTH_OTHER_DESC', 'name'=>'Other', 'urlforcredentials'=>'', 'availablescopes'=>'Standard', 'returnurl'=>'/core/modules/oauth/generic_oauthcallback.php');
// See https://learn.microsoft.com/fr-fr/azure/active-directory/develop/quickstart-register-app#register-an-application
diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php
index b0e283fc17a..f7d8ea37649 100644
--- a/htdocs/emailcollector/class/emailcollector.class.php
+++ b/htdocs/emailcollector/class/emailcollector.class.php
@@ -865,7 +865,7 @@ class EmailCollector extends CommonObject
/**
* overwitePropertiesOfObject
*
- * @param object $object Current object
+ * @param object $object Current object we will set ->properties
* @param string $actionparam Action parameters
* @param string $messagetext Body
* @param string $subject Subject
@@ -896,8 +896,13 @@ class EmailCollector extends CommonObject
// Overwrite values with values extracted from source email
// $this->actionparam = 'opportunity_status=123;abc=EXTRACT:BODY:....'
$arrayvaluetouse = dolExplodeIntoArray($actionparam, '(\n\r|\r|\n|;)', '=');
+
+ $tmp = array();
+
+ // Loop on each property set into actionparam
foreach ($arrayvaluetouse as $propertytooverwrite => $valueforproperty) {
- $tmpclass = ''; $tmpproperty = '';
+ $tmpclass = '';
+ $tmpproperty = '';
$tmparray = explode('.', $propertytooverwrite);
if (count($tmparray) == 2) {
$tmpclass = $tmparray[0];
@@ -952,23 +957,39 @@ class EmailCollector extends CommonObject
if (preg_match('/^options_/', $tmpproperty)) {
$object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $this->decodeSMTPSubject($valueextracted);
} else {
- $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted);
+ if (property_exists($object, $tmpproperty)) {
+ $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted);
+ } else {
+ $tmp[$tmpproperty] = $this->decodeSMTPSubject($valueextracted);
+ }
}
} else { // extract from BODY
if (preg_match('/^options_/', $tmpproperty)) {
$object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $this->decodeSMTPSubject($valueextracted);
} else {
- $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted);
+ if (property_exists($object, $tmpproperty)) {
+ $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted);
+ } else {
+ $tmp[$tmpproperty] = $this->decodeSMTPSubject($valueextracted);
+ }
}
}
if (preg_match('/^options_/', $tmpproperty)) {
$operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> found '.dol_escape_htmltag(dol_trunc($object->array_options[preg_replace('/^options_/', '', $tmpproperty)], 128));
} else {
- $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> found '.dol_escape_htmltag(dol_trunc($object->$tmpproperty, 128));
+ if (property_exists($object, $tmpproperty)) {
+ $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> found '.dol_escape_htmltag(dol_trunc($object->$tmpproperty, 128));
+ } else {
+ $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> found '.dol_escape_htmltag(dol_trunc($tmp[$tmpproperty], 128));
+ }
}
} else {
// Regex not found
- $object->$tmpproperty = null;
+ if (property_exists($object, $tmpproperty)) {
+ $object->$tmpproperty = null;
+ } else {
+ $tmp[$tmpproperty] = null;
+ }
$operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> not found, so property '.dol_escape_htmltag($tmpproperty).' is set to null.';
}
@@ -983,7 +1004,11 @@ class EmailCollector extends CommonObject
if (preg_match('/^options_/', $tmpproperty)) {
$valuecurrent = $object->array_options[preg_replace('/^options_/', '', $tmpproperty)];
} else {
- $valuecurrent = $object->$tmpproperty;
+ if (property_exists($object, $tmpproperty)) {
+ $valuecurrent = $object->$tmpproperty;
+ } else {
+ $valuecurrent = $tmp[$tmpproperty];
+ }
}
if ($regforregex[1] == 'SET' || empty($valuecurrent)) {
@@ -993,24 +1018,38 @@ class EmailCollector extends CommonObject
$matcharray = array();
preg_match_all('/__([a-z0-9]+(?:_[a-z0-9]+)?)__/i', $valuetouse, $matcharray);
//var_dump($tmpproperty.' - '.$object->$tmpproperty.' - '.$valuetouse); var_dump($matcharray);
- if (is_array($matcharray[1])) { // $matcharray[1] is array with list of substitution key found without the __
+ if (is_array($matcharray[1])) { // $matcharray[1] is an array with the list of substitution key found without the __X__ syntax into the SET entry
foreach ($matcharray[1] as $keytoreplace) {
- if ($keytoreplace && isset($object->$keytoreplace)) {
- $substitutionarray['__'.$keytoreplace.'__'] = $object->$keytoreplace;
+ if ($keytoreplace) {
+ if (preg_match('/^options_/', $keytoreplace)) {
+ $substitutionarray['__'.$keytoreplace.'__'] = $object->array_options[preg_replace('/^options_/', '', $keytoreplace)];
+ } else {
+ if (property_exists($object, $keytoreplace)) {
+ $substitutionarray['__'.$keytoreplace.'__'] = $object->$keytoreplace;
+ } else {
+ $substitutionarray['__'.$keytoreplace.'__'] = $tmp[$keytoreplace];
+ }
+ }
}
}
}
//var_dump($substitutionarray);
- dol_syslog(var_export($substitutionarray, true));
+ dol_syslog('substitutionarray='.var_export($substitutionarray, true));
//var_dump($substitutionarray);
$valuetouse = make_substitutions($valuetouse, $substitutionarray);
if (preg_match('/^options_/', $tmpproperty)) {
$object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $valuetouse;
- } else {
- $object->$tmpproperty = $valuetouse;
- }
- $operationslog .= '
Set value '.dol_escape_htmltag($valuetouse).' into variable '.dol_escape_htmltag($tmpproperty);
+ $operationslog .= '
Set value '.dol_escape_htmltag($valuetouse).' into object->array_options['.dol_escape_htmltag(preg_replace('/^options_/', '', $tmpproperty)).']';
+ } else {
+ if (property_exists($object, $tmpproperty)) {
+ $object->$tmpproperty = $valuetouse;
+ } else {
+ $tmp[$tmpproperty] = $valuetouse;
+ }
+
+ $operationslog .= '
Set value '.dol_escape_htmltag($valuetouse).' into object->'.dol_escape_htmltag($tmpproperty);
+ }
}
} else {
$errorforthisaction++;
@@ -1041,7 +1080,7 @@ class EmailCollector extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/includes/webklex/php-imap/vendor/autoload.php';
}
- dol_syslog("EmailCollector::doCollectOneCollector start for id=".$this->id." - ".$this->ref, LOG_DEBUG);
+ dol_syslog("EmailCollector::doCollectOneCollector start for id=".$this->id." - ".$this->ref, LOG_INFO);
$langs->loadLangs(array("project", "companies", "mails", "errors", "ticket", "agenda", "commercial"));
@@ -1470,6 +1509,9 @@ class EmailCollector extends CommonObject
try {
//var_dump($Query->count());
+ if ($mode > 0) {
+ $Query->leaveUnread();
+ }
$arrayofemail = $Query->limit($this->maxemailpercollect)->setFetchOrder("asc")->get();
//var_dump($arrayofemail);
} catch (Exception $e) {
@@ -2016,6 +2058,7 @@ class EmailCollector extends CommonObject
$result = $contactstatic->fetch(0, null, '', $from);
if ($result > 0) {
+ dol_syslog("We found a contact with the email ".$from);
$contactid = $contactstatic->id;
$contactfoundby = 'email of contact ('.$from.')';
if (empty($thirdpartyid) && $contactstatic->socid > 0) {
@@ -2031,12 +2074,44 @@ class EmailCollector extends CommonObject
if (empty($thirdpartyid)) { // Try to find thirdparty using email
$result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $from);
if ($result > 0) {
+ dol_syslog("We found a thirdparty with the email ".$from);
+ $thirdpartyid = $thirdpartystatic->id;;
$thirdpartyfoundby = 'email ('.$from.')';
}
}
- // Do operations
- if ($mode < 2) {
+ /*
+ if ($replyto) {
+ if (empty($contactid)) { // Try to find contact using email
+ $result = $contactstatic->fetch(0, null, '', $replyto);
+
+ if ($result > 0) {
+ dol_syslog("We found a contact with the email ".$replyto);
+ $contactid = $contactstatic->id;
+ $contactfoundby = 'email of contact ('.$replyto.')';
+ if (empty($thirdpartyid) && $contactstatic->socid > 0) {
+ $result = $thirdpartystatic->fetch($contactstatic->socid);
+ if ($result > 0) {
+ $thirdpartyid = $thirdpartystatic->id;
+ $thirdpartyfoundby = 'email of contact ('.$replyto.')';
+ }
+ }
+ }
+ }
+
+ if (empty($thirdpartyid)) { // Try to find thirdparty using email
+ $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto);
+ if ($result > 0) {
+ dol_syslog("We found a thirdparty with the email ".$replyto);
+ $thirdpartyid = $thirdpartystatic->id;;
+ $thirdpartyfoundby = 'email ('.$replyto.')';
+ }
+ }
+ }
+ */
+
+ // 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
foreach ($this->actions as $operation) {
$errorforthisaction = 0;
@@ -2047,6 +2122,8 @@ class EmailCollector extends CommonObject
continue;
}
+ $operationslog .= '
* Process operation '.$operation['type'];
+
// Make Operation
dol_syslog("Execute action ".$operation['type']." actionparam=".$operation['actionparam'].' thirdpartystatic->id='.$thirdpartystatic->id.' contactstatic->id='.$contactstatic->id.' projectstatic->id='.$projectstatic->id);
dol_syslog("Execute action fk_element_id=".$fk_element_id." fk_element_type=".$fk_element_type); // If a Dolibarr tracker id is found, we should now the id of object
@@ -2084,6 +2161,8 @@ class EmailCollector extends CommonObject
$emailtouseforthirdparty = '';
$namealiastouseforthirdparty = '';
+ $operationslog .= '
Loop on each property to set into actionparam';
+
// $actionparam = 'param=SET:aaa' or 'param=EXTRACT:BODY:....'
$arrayvaluetouse = dolExplodeIntoArray($actionparam, '(\n\r|\r|\n|;)', '=');
foreach ($arrayvaluetouse as $propertytooverwrite => $valueforproperty) {
@@ -2115,21 +2194,21 @@ class EmailCollector extends CommonObject
if ($propertytooverwrite == 'id') {
$idtouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null;
- $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found idtouseforthirdparty='.dol_escape_htmltag($idtouseforthirdparty);
+ $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found idtouseforthirdparty='.dol_escape_htmltag($idtouseforthirdparty);
} elseif ($propertytooverwrite == 'email') {
$emailtouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null;
- $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found emailtouseforthirdparty='.dol_escape_htmltag($emailtouseforthirdparty);
+ $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found emailtouseforthirdparty='.dol_escape_htmltag($emailtouseforthirdparty);
} elseif ($propertytooverwrite == 'name') {
$nametouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null;
- $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty);
+ $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty);
} elseif ($propertytooverwrite == 'name_alias') {
- $nametouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null;
+ $namealiastouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null;
- $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found namealiastouseforthirdparty='.dol_escape_htmltag($namealiastouseforthirdparty);
+ $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found namealiastouseforthirdparty='.dol_escape_htmltag($namealiastouseforthirdparty);
} else {
- $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> We discard this, not used to search existing thirdparty';
+ $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> We discard this, not used to search existing thirdparty';
}
} else {
// Regex not found
@@ -2138,7 +2217,7 @@ class EmailCollector extends CommonObject
$emailtouseforthirdparty = null;
$namealiastouseforthirdparty = null;
- $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Not found';
+ $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Not found';
}
//var_dump($object->$tmpproperty);exit;
} else {
@@ -2154,19 +2233,19 @@ class EmailCollector extends CommonObject
if ($propertytooverwrite == 'id') {
$idtouseforthirdparty = $reg[2];
- $operationslog .= '
We set property idtouseforthrdparty='.dol_escape_htmltag($idtouseforthirdparty);
+ $operationslog .= '
propertytooverwrite='.$propertytooverwrite.'We set property idtouseforthrdparty='.dol_escape_htmltag($idtouseforthirdparty);
} elseif ($propertytooverwrite == 'email') {
$emailtouseforthirdparty = $reg[2];
- $operationslog .= '
We set property emailtouseforthrdparty='.dol_escape_htmltag($emailtouseforthirdparty);
+ $operationslog .= '
propertytooverwrite='.$propertytooverwrite.'We set property emailtouseforthrdparty='.dol_escape_htmltag($emailtouseforthirdparty);
} elseif ($propertytooverwrite == 'name') {
$nametouseforthirdparty = $reg[2];
- $operationslog .= '
We set property nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty);
+ $operationslog .= '
propertytooverwrite='.$propertytooverwrite.'We set property nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty);
} elseif ($propertytooverwrite == 'name_alias') {
$namealiastouseforthirdparty = $reg[2];
- $operationslog .= '
We set property namealiastouseforthirdparty='.dol_escape_htmltag($namealiastouseforthirdparty);
+ $operationslog .= '
propertytooverwrite='.$propertytooverwrite.'We set property namealiastouseforthirdparty='.dol_escape_htmltag($namealiastouseforthirdparty);
}
} else {
$errorforactions++;
@@ -2177,6 +2256,25 @@ class EmailCollector extends CommonObject
}
if (!$errorforactions && ($idtouseforthirdparty || $emailtouseforthirdparty || $nametouseforthirdparty || $namealiastouseforthirdparty)) {
+ // We make another search on thirdparty
+ $operationslog .= '
We have this data to search thirdparty: '.$idtouseforthirdparty.' '.$emailtouseforthirdparty.' '.$nametouseforthirdparty.' '.$namealiastouseforthirdparty;
+
+ $tmpobject = new stdClass();
+ $tmpobject->element == 'generic';
+ $tmpobject->id = $idtouseforthirdparty;
+ $tmpobject->name = $nametouseforthirdparty;
+ $tmpobject->name_alias = $namealiastouseforthirdparty;
+ $tmpobject->email = $emailtouseforthirdparty;
+
+ $this->overwritePropertiesOfObject($tmpobject, $operation['actionparam'], $messagetext, $subject, $header, $operationslog);
+
+ $idtouseforthirdparty = $tmpobject->id;
+ $nametouseforthirdparty = $tmpobject->name;
+ $namealiastouseforthirdparty = $tmpobject->name_alias;
+ $emailtouseforthirdparty = $tmpobject->email;
+
+ $operationslog .= '
We try to search existing thirdparty with '.$idtouseforthirdparty.' '.$emailtouseforthirdparty.' '.$nametouseforthirdparty.' '.$namealiastouseforthirdparty;
+
$result = $thirdpartystatic->fetch($idtouseforthirdparty, $nametouseforthirdparty, '', '', '', '', '', '', '', '', $emailtouseforthirdparty, $namealiastouseforthirdparty);
if ($result < 0) {
$errorforactions++;
@@ -2195,6 +2293,7 @@ class EmailCollector extends CommonObject
dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." name_alias=".$namealiastouseforthirdparty." was not found. We try to create it.");
// Create thirdparty
+ $thirdpartystatic = new Societe($db);
$thirdpartystatic->name = $nametouseforthirdparty;
if (!empty($namealiastouseforthirdparty)) {
if ($namealiastouseforthirdparty != $nametouseforthirdparty) {
@@ -2230,6 +2329,8 @@ class EmailCollector extends CommonObject
}
} else {
dol_syslog("One and only one existing third party has been found");
+
+ $operationslog .= '
Thirdparty already exists with id = '.dol_escape_htmltag($thirdpartystatic->id);
}
}
}
@@ -2726,6 +2827,8 @@ class EmailCollector extends CommonObject
}
}
} else {
+ dol_syslog("Project already exists for msgid = ".dol_escape_htmltag($msgid).", so we do not recreate it.");
+
$operationslog .= '
Project already exists for msgid ='.dol_escape_htmltag($msgid);
}
} elseif ($operation['type'] == 'ticket') {
@@ -2995,9 +3098,9 @@ class EmailCollector extends CommonObject
// Error for email or not ?
if (!$errorforactions) {
- if ($targetdir && empty($mode)) {
+ if (!empty($targetdir) && empty($mode)) {
if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
- dol_syslog("EmailCollector::doCollectOneCollector move message ".$imapemail." to ".$connectstringtarget, LOG_DEBUG);
+ dol_syslog("EmailCollector::doCollectOneCollector move message ".((string) $imapemail)." to ".$connectstringtarget, LOG_DEBUG);
$res = imap_mail_move($connection, $imapemail, $targetdir, 0);
if ($res == false) {
$errorforemail++;
@@ -3006,7 +3109,9 @@ class EmailCollector extends CommonObject
dol_syslog(imap_last_error());
}
} else {
- // TODO Move mail using PHP-IMAP
+ // Move mail using PHP-IMAP
+ dol_syslog("EmailCollector::doCollectOneCollector move message ".($imapemail->getHeader()->get('subject'))." to ".$targetdir, LOG_DEBUG);
+ $imapemail->move($targetdir);
}
} else {
if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
@@ -3059,7 +3164,8 @@ class EmailCollector extends CommonObject
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
$client->disconnect();
} else {
- if (empty($mode)) {
+ if (empty($mode) && empty($error)) {
+ dol_syslog("Expunge", LOG_DEBUG);
imap_expunge($connection); // To validate any move
}
imap_close($connection);
@@ -3088,7 +3194,7 @@ class EmailCollector extends CommonObject
$this->update($user);
}
- dol_syslog("EmailCollector::doCollectOneCollector end", LOG_DEBUG);
+ dol_syslog("EmailCollector::doCollectOneCollector end", LOG_INFO);
return $error ? -1 : 1;
}
diff --git a/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php b/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php
index 90c20405e6b..6c3b18b3c0f 100644
--- a/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php
+++ b/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php
@@ -38,8 +38,8 @@ class Microsoft extends AbstractService
const SCOPE_APPLICATIONS = 'applications';
const SCOPE_APPLICATIONS_CREATE = 'applications_create';
const SCOPE_IMAP = 'imap';
- const SOCPE_IMAP_ACCESSASUSERALL = 'https://outlook.office.com/IMAP.AccessAsUser.All';
- const SOCPE_SMTPSEND = 'https://outlook.office.com/SMTP.Send';
+ const SOCPE_IMAP_ACCESSASUSERALL = 'https://outlook.office365.com/IMAP.AccessAsUser.All';
+ const SOCPE_SMTPSEND = 'https://outlook.office365.com/SMTP.Send';
const SOCPE_USERREAD = 'User.Read';
const SOCPE_MAILREAD = 'Mail.Read';
const SOCPE_MAILSEND = 'Mail.Send';
diff --git a/htdocs/includes/webklex/php-imap/vendor/autoload.php b/htdocs/includes/webklex/php-imap/vendor/autoload.php
index 298bedf9b9c..12f2cb6cb45 100644
--- a/htdocs/includes/webklex/php-imap/vendor/autoload.php
+++ b/htdocs/includes/webklex/php-imap/vendor/autoload.php
@@ -17,6 +17,13 @@ return ComposerAutoloaderInit4da13270269c89a28e472e1f7324e6d1::getLoader();
// Add class/method of PHP8 for compatibility with older versions of PHP
require_once(__DIR__.'/symfony/polyfill-php80/bootstrap.php');
+//'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
+//'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
+//'60799491728b879e74601d83e38b2cad' => $vendorDir . '/illuminate/collections/helpers.php',
+//'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
+//'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
+require_once(__DIR__.'/illuminate/collections/helpers.php');
+
spl_autoload_register(function ($class_name) {
// Enable this to detect what we need for require_once