Merge pull request #22258 from dolibit-ut/patch-602

Update emailcollector.class.php
This commit is contained in:
Laurent Destailleur 2022-09-20 01:08:17 +02:00 committed by GitHub
commit f47364ae93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,37 +16,38 @@
*/ */
/** /**
* \file emailcollector/class/emailcollector.class.php * \file htdocs/emailcollector/class/emailcollector.class.php
* \ingroup emailcollector * \ingroup emailcollector
* \brief This file is a CRUD class file for EmailCollector (Create/Read/Update/Delete) * \brief This file is a CRUD class file for EmailCollector (Create/Read/Update/Delete)
*/ */
// Put here all includes required by your class file // Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; include_once DOL_DOCUMENT_ROOT .'/emailcollector/lib/emailcollector.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; // customer proposal require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; // customer order require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; // Shipment
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; // supplier invoice require_once DOL_DOCUMENT_ROOT .'/comm/propal/class/propal.class.php'; // Customer Proposal
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; // supplier order require_once DOL_DOCUMENT_ROOT .'/commande/class/commande.class.php'; // Customer Order
require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; // supplier proposal require_once DOL_DOCUMENT_ROOT .'/compta/facture/class/facture.class.php'; // Customer Invoice
require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; // reception require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php'; // Contact / Address
include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php'; require_once DOL_DOCUMENT_ROOT .'/expedition/class/expedition.class.php'; // Shipping / Delivery
//require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; // Holidays (leave request) require_once DOL_DOCUMENT_ROOT .'/fourn/class/fournisseur.commande.class.php'; // Supplier Order
//require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; // expernse repor require_once DOL_DOCUMENT_ROOT .'/fourn/class/fournisseur.facture.class.php'; // Supplier Invoice
require_once DOL_DOCUMENT_ROOT .'/projet/class/project.class.php'; // Project
require_once DOL_DOCUMENT_ROOT .'/reception/class/reception.class.php'; // Reception
require_once DOL_DOCUMENT_ROOT .'/recruitment/class/recruitmentcandidature.class.php'; // Recruiting
require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; // Third-Party
require_once DOL_DOCUMENT_ROOT .'/supplier_proposal/class/supplier_proposal.class.php'; // Supplier Proposal
require_once DOL_DOCUMENT_ROOT .'/ticket/class/ticket.class.php'; // Ticket
//require_once DOL_DOCUMENT_ROOT .'/expensereport/class/expensereport.class.php'; // Expense Report
//require_once DOL_DOCUMENT_ROOT .'/holiday/class/holiday.class.php'; // Holidays (leave request)
// use Webklex\PHPIMAP; // use Webklex\PHPIMAP;
require DOL_DOCUMENT_ROOT.'/includes/webklex/php-imap/vendor/autoload.php'; require DOL_DOCUMENT_ROOT .'/includes/webklex/php-imap/vendor/autoload.php';
use Webklex\PHPIMAP\ClientManager;
use Webklex\PHPIMAP\ClientManager;
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException; use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
use Webklex\PHPIMAP\Exceptions\InvalidWhereQueryCriteriaException; use Webklex\PHPIMAP\Exceptions\InvalidWhereQueryCriteriaException;
use Webklex\PHPIMAP\Exceptions\GetMessagesFailedException; use Webklex\PHPIMAP\Exceptions\GetMessagesFailedException;
@ -64,14 +65,17 @@ class EmailCollector extends CommonObject
* @var string ID to identify managed object * @var string ID to identify managed object
*/ */
public $element = 'emailcollector'; public $element = 'emailcollector';
/** /**
* @var string Name of table without prefix where object is stored * @var string Name of table without prefix where object is stored
*/ */
public $table_element = 'emailcollector_emailcollector'; public $table_element = 'emailcollector_emailcollector';
/** /**
* @var int Does emailcollector support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe * @var int Does emailcollector support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/ */
public $ismultientitymanaged = 1; public $ismultientitymanaged = 1;
/** /**
* @var int Does emailcollector support extrafields ? 0=No, 1=Yes * @var int Does emailcollector support extrafields ? 0=No, 1=Yes
*/ */
@ -91,6 +95,7 @@ class EmailCollector extends CommonObject
* @var array List of child tables. To test if we can delete object. * @var array List of child tables. To test if we can delete object.
*/ */
protected $childtables = array(); protected $childtables = array();
/** /**
* @var array List of child tables. To know object to delete on cascade. * @var array List of child tables. To know object to delete on cascade.
*/ */
@ -206,7 +211,6 @@ class EmailCollector extends CommonObject
*/ */
public $import_key; public $import_key;
public $host; public $host;
public $port; public $port;
public $hostcharset; public $hostcharset;
@ -1747,61 +1751,61 @@ class EmailCollector extends CommonObject
$objectid = $reg[2]; $objectid = $reg[2];
// See also list into interface_50_modAgenda_ActionsAuto // See also list into interface_50_modAgenda_ActionsAuto
if ($reg[1] == 'thi') { if ($reg[1] == 'thi') { // Third-party
$objectemail = new Societe($this->db); $objectemail = new Societe($this->db);
} }
if ($reg[1] == 'ctc') { if ($reg[1] == 'ctc') { // Contact
$objectemail = new Contact($this->db); $objectemail = new Contact($this->db);
} }
if ($reg[1] == 'inv') { // customer invoices if ($reg[1] == 'inv') { // Customer Invoice
$objectemail = new Facture($this->db); $objectemail = new Facture($this->db);
} }
if ($reg[1] == 'sinv') { // supplier invoices if ($reg[1] == 'sinv') { // Supplier Invoice
$objectemail = new FactureFournisseur($this->db); $objectemail = new FactureFournisseur($this->db);
} }
if ($reg[1] == 'pro') { // customer proposals if ($reg[1] == 'pro') { // Customer Proposal
$objectemail = new Propal($this->db); $objectemail = new Propal($this->db);
} }
if ($reg[1] == 'ord') { // customer orders if ($reg[1] == 'ord') { // Customer Order
$objectemail = new Commande($this->db); $objectemail = new Commande($this->db);
} }
if ($reg[1] == 'shi') { // shipments if ($reg[1] == 'shi') { // Shipment
$objectemail = new Expedition($this->db); $objectemail = new Expedition($this->db);
} }
if ($reg[1] == 'spro') { // supplier proposal if ($reg[1] == 'spro') { // Supplier Proposal
$objectemail = new SupplierProposal($this->db); $objectemail = new SupplierProposal($this->db);
} }
if ($reg[1] == 'sord') { // supplier order if ($reg[1] == 'sord') { // Supplier Order
$objectemail = new CommandeFournisseur($this->db); $objectemail = new CommandeFournisseur($this->db);
} }
if ($reg[1] == 'rec') { // Reception if ($reg[1] == 'rec') { // Reception
$objectemail = new Reception($this->db); $objectemail = new Reception($this->db);
} }
if ($reg[1] == 'proj') { if ($reg[1] == 'proj') { // Project
$objectemail = new Project($this->db); $objectemail = new Project($this->db);
} }
if ($reg[1] == 'tas') { if ($reg[1] == 'tas') { // Task
$objectemail = new Task($this->db); $objectemail = new Task($this->db);
} }
if ($reg[1] == 'con') { if ($reg[1] == 'con') { // Contact
$objectemail = new Contact($this->db); $objectemail = new Contact($this->db);
} }
if ($reg[1] == 'use') { if ($reg[1] == 'use') { // User
$objectemail = new User($this->db); $objectemail = new User($this->db);
} }
if ($reg[1] == 'tic') { if ($reg[1] == 'tic') { // Ticket
$objectemail = new Ticket($this->db); $objectemail = new Ticket($this->db);
} }
if ($reg[1] == 'recruitmentcandidature') { if ($reg[1] == 'recruitmentcandidature') { // Recruiting Candidate
$objectemail = new RecruitmentCandidature($this->db); $objectemail = new RecruitmentCandidature($this->db);
} }
if ($reg[1] == 'mem') { if ($reg[1] == 'mem') { // Member
$objectemail = new Adherent($this->db); $objectemail = new Adherent($this->db);
} }
/*if ($reg[1] == 'leav') { /*if ($reg[1] == 'leav') { // Leave / Holiday
$objectemail = new Holiday($db); $objectemail = new Holiday($db);
} }
if ($reg[1] == 'exp') { if ($reg[1] == 'exp') { // ExpenseReport
$objectemail = new ExpenseReport($db); $objectemail = new ExpenseReport($db);
}*/ }*/
} elseif (preg_match('/<(.*@.*)>/', $reference, $reg)) { } elseif (preg_match('/<(.*@.*)>/', $reference, $reg)) {
@ -2241,42 +2245,42 @@ class EmailCollector extends CommonObject
} }
$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/recruitmentjobposition' => array('table' => 'recruitment_recruitmentcandidature', 'recruitment/recruitmentjobposition' => 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'),
@ -2284,51 +2288,51 @@ class EmailCollector extends CommonObject
'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'),
@ -2932,6 +2936,7 @@ class EmailCollector extends CommonObject
2.2.1 text/plain 2.2.1 text/plain
2.2.2 text/html 2.2.2 text/html
*/ */
/** /**
* Sub function for getpart(). Only called by createPartArray() and itself. * Sub function for getpart(). Only called by createPartArray() and itself.
* *
@ -3050,10 +3055,10 @@ class EmailCollector extends CommonObject
/** /**
* Converts a string from one encoding to another. * Converts a string from one encoding to another.
* *
* @param string $string String to convert * @param string $string String to convert
* @param string $fromEncoding String encoding * @param string $fromEncoding String encoding
* @param string $toEncoding String return encoding * @param string $toEncoding String return encoding
* @return string Converted string if conversion was successful, or the original string if not * @return string Converted string if conversion was successful, or the original string if not
* @throws Exception * @throws Exception
*/ */
protected function convertStringEncoding($string, $fromEncoding, $toEncoding = 'UTF-8') protected function convertStringEncoding($string, $fromEncoding, $toEncoding = 'UTF-8')