Qual: Fix PhanPluginUnknownObjectMethodCall in classes with high occurence (#30754)
* Qual: Fix PhanPluginUnknownObjectMethodCall in import.php * Qual: PHPDoc for import/export array types * Qual: Add PHPDoc types to import.class.php * Fix PhanPluginUnknownObjectMethodCall in stats.class.php * Add methods expected on ModeleImport child classes * Force imapemail type for phan * Qual: Update phan baseline * Qual: Fix Undefined/Undeclared phan notices in module_help * Update baseline
This commit is contained in:
parent
03ffbd3099
commit
f5c7ca1769
9 changed files with 355 additions and 70 deletions
|
|
@ -119,7 +119,7 @@ return [
|
|||
'htdocs/admin/mails_templates.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanRedefineFunction', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/admin/menus.php' => ['PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/admin/menus/edit.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
|
||||
'htdocs/admin/modulehelp.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchDimFetchNullable', 'PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/admin/modulehelp.php' => ['PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/admin/modules.php' => ['PhanEmptyFQSENInClasslike', 'PhanInvalidFQSENInClasslike', 'PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/admin/mrp.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
|
||||
'htdocs/admin/mrp_extrafields.php' => ['PhanUndeclaredGlobalVariable'],
|
||||
|
|
@ -470,7 +470,7 @@ return [
|
|||
'htdocs/core/class/rssparser.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeExpectedObjectPropAccess'],
|
||||
'htdocs/core/class/smtps.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchDimFetch'],
|
||||
'htdocs/core/class/socialnetworkmanager.class.php' => ['PhanPluginUnknownArrayMethodParamType'],
|
||||
'htdocs/core/class/stats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchDimFetch'],
|
||||
'htdocs/core/class/stats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchDimFetch'],
|
||||
'htdocs/core/class/timespent.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
|
||||
'htdocs/core/class/translate.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'],
|
||||
'htdocs/core/class/utils.class.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'],
|
||||
|
|
@ -603,7 +603,7 @@ return [
|
|||
'htdocs/core/modules/hrm/mod_evaluation_advanced.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
|
||||
'htdocs/core/modules/import/import_csv.modules.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
|
||||
'htdocs/core/modules/import/import_xlsx.modules.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
|
||||
'htdocs/core/modules/import/modules_import.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchDimFetch'],
|
||||
'htdocs/core/modules/import/modules_import.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchDimFetch'],
|
||||
'htdocs/core/modules/mailings/advthirdparties.modules.php' => ['PhanPluginUnknownArrayMethodParamType'],
|
||||
'htdocs/core/modules/mailings/contacts1.modules.php' => ['PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/core/modules/mailings/modules_mailings.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType'],
|
||||
|
|
@ -703,7 +703,6 @@ return [
|
|||
'htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
|
||||
'htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php' => ['PhanPluginUnknownObjectMethodCall'],
|
||||
'htdocs/core/triggers/interface_50_modEventOrganization_EventOrganization.class.php' => ['PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php' => ['PhanPluginUnknownObjectMethodCall'],
|
||||
'htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php' => ['PhanPluginUnknownObjectMethodCall'],
|
||||
'htdocs/core/triggers/interface_50_modNotification_Notification.class.php' => ['PhanPluginUnknownArrayMethodReturnType'],
|
||||
'htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeExpectedObjectPropAccess'],
|
||||
|
|
@ -752,7 +751,7 @@ return [
|
|||
'htdocs/ecm/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/ecm/index_auto.php' => ['PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/ecm/index_medias.php' => ['PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/emailcollector/class/emailcollector.class.php' => ['PhanInvalidFQSENInClasslike', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
|
||||
'htdocs/emailcollector/class/emailcollector.class.php' => ['PhanInvalidFQSENInClasslike', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
|
||||
'htdocs/emailcollector/class/emailcollectoraction.class.php' => ['PhanPluginUnknownPropertyType'],
|
||||
'htdocs/emailcollector/class/emailcollectorfilter.class.php' => ['PhanPluginUnknownPropertyType'],
|
||||
'htdocs/emailcollector/lib/emailcollector.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
|
||||
|
|
@ -864,9 +863,9 @@ return [
|
|||
'htdocs/hrm/skill_card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
|
||||
'htdocs/hrm/skill_list.php' => ['PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/hrm/skill_tab.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/imports/class/import.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType'],
|
||||
'htdocs/imports/class/import.class.php' => ['PhanPluginEmptyStatementIf'],
|
||||
'htdocs/imports/emptyexample.php' => ['PhanRedefineFunction', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/imports/import.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/imports/import.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/install/check.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'],
|
||||
'htdocs/install/fileconf.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'],
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ $modulesdir = dolGetModulesDirs();
|
|||
|
||||
|
||||
$filename = array();
|
||||
'@phan-var-force DolibarrModules[] $modules';
|
||||
$modules = array();
|
||||
$orders = array();
|
||||
$categ = array();
|
||||
|
|
@ -225,10 +226,13 @@ asort($orders);
|
|||
//var_dump($modules);
|
||||
|
||||
|
||||
unset($objMod);
|
||||
$objMod = null;
|
||||
$dirofmodule = null;
|
||||
$key = -1;
|
||||
$i = 0;
|
||||
foreach ($orders as $tmpkey => $tmpvalue) {
|
||||
$tmpMod = $modules[$tmpkey];
|
||||
'@phan-var-force DolibarrModules $tmpMod';
|
||||
if ($tmpMod->numero == $id) {
|
||||
$key = $i;
|
||||
$modName = $filename[$tmpkey];
|
||||
|
|
@ -238,6 +242,12 @@ foreach ($orders as $tmpkey => $tmpvalue) {
|
|||
}
|
||||
$i++;
|
||||
}
|
||||
if (!is_object($objMod)) {
|
||||
$msg = __FILE__." Module with no found for id:".$id;
|
||||
dol_syslog($msg, LOG_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
$value = $orders[$key];
|
||||
$tab = explode('_', $value);
|
||||
$familyposition = $tab[0];
|
||||
|
|
@ -346,11 +356,11 @@ if ($mode == 'desc') {
|
|||
|
||||
$textexternal = '';
|
||||
if ($objMod->isCoreOrExternalModule() == 'external') {
|
||||
$tmpdirofmoduletoshow = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $dirofmodule);
|
||||
$tmpdirofmoduletoshow = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', (string) $dirofmodule);
|
||||
$textexternal .= '<br><span class="opacitymedium">'.$langs->trans("Origin").':</span> '.$langs->trans("ExternalModule").' - '.$langs->trans("InstalledInto", $tmpdirofmoduletoshow);
|
||||
|
||||
global $dolibarr_allow_download_external_modules;
|
||||
if (!empty($dolibarr_allow_download_external_modules) && preg_match('/\/custom\//', $dirofmodule)) {
|
||||
if (!empty($dolibarr_allow_download_external_modules) && preg_match('/\/custom\//', (string) $dirofmodule)) {
|
||||
// Add a link to download a zip of the module
|
||||
$textexternal .= ' <a href="'.DOL_URL_ROOT.'/admin/tools/export_files.php?export_type=externalmodule&what='.urlencode($moduledir).'&compression=zip&zipfilename_template=module_'.$moduledir.'-'.$version.'.notorig" target="_blank" rel="noopener">'.img_picto('', 'download').'</a>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,14 @@
|
|||
*/
|
||||
abstract class Stats
|
||||
{
|
||||
/**
|
||||
* @var DoliDB
|
||||
*/
|
||||
protected $db;
|
||||
protected $lastfetchdate = array(); // Dates of cache file read by methods
|
||||
/**
|
||||
* @var array<string,int> Dates of cache file read by methods
|
||||
*/
|
||||
protected $lastfetchdate = array();
|
||||
public $cachefilesuffix = ''; // Suffix to add to name of cache file (to avoid file name conflicts)
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||
// For exports
|
||||
|
||||
/**
|
||||
* @var string Module export code
|
||||
* @var string[] Module export code
|
||||
*/
|
||||
public $export_code;
|
||||
|
||||
|
|
@ -252,23 +252,68 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||
*/
|
||||
public $export_label;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $export_icon;
|
||||
|
||||
/**
|
||||
* @var array export enabled
|
||||
* @var string[] export enabled (list of php expressions, '1' or "isModEnabled('xxx')...")
|
||||
*/
|
||||
public $export_enabled;
|
||||
/**
|
||||
* @var array<array<array{string,string}>>
|
||||
*/
|
||||
public $export_permission;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $export_fields_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $export_TypeFields_array; // Array of key=>type where type can be 'Numeric', 'Date', 'Text', 'Boolean', 'Status', 'List:xxx:fieldlabel:rowid'
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $export_entities_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $export_aggregate_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $export_examplevalues_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $export_help_array;
|
||||
/**
|
||||
* @var array<array<array{rule:string,file:string,classfile:string,class:string,method:string,method_params:string[]}>>|array<array<string,string>>
|
||||
*
|
||||
* Other example:
|
||||
* modBanque: [<int>]=array('-b.amount'=>'NULLIFNEG', 'b.amount'=>'NULLIFNEG')
|
||||
*/
|
||||
public $export_special_array; // special or computed field
|
||||
/**
|
||||
* @var array<int,array<string,string|string[]>>
|
||||
*
|
||||
* Note: example from modAdherent: [<int]= array('subscription'=>'c.rowid');
|
||||
* example from modResource: [<int]= array('resource' => array('r.rowid'));
|
||||
*/
|
||||
public $export_dependencies_array;
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $export_sql_start;
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $export_sql_end;
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $export_sql_order;
|
||||
|
||||
|
||||
|
|
@ -284,18 +329,57 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||
*/
|
||||
public $import_label;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $import_icon;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $import_entities_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $import_tables_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $import_tables_creator_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $import_fields_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $import_fieldshidden_array;
|
||||
/**
|
||||
* @var array<array<array{rule:string,file:string,class:string,method:string}>>
|
||||
*/
|
||||
public $import_convertvalue_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $import_regex_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $import_examplevalues_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $import_updatekeys_array;
|
||||
/**
|
||||
* @var array<int,array<int,string>>
|
||||
*/
|
||||
public $import_run_sql_after_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $import_TypeFields_array;
|
||||
/**
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $import_help_array;
|
||||
|
||||
/**
|
||||
|
|
@ -336,8 +420,11 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||
|
||||
|
||||
/**
|
||||
* @var array List of module class names that must be enabled if this module is enabled. e.g.: array('modAnotherModule', 'FR'=>'modYetAnotherModule')
|
||||
* @var string[]|array<string,string[]> List of module class names that must be enabled if this module is enabled. e.g.: array('modAnotherModule', 'FR'=>'modYetAnotherModule')
|
||||
* Another example : array('always'=>array("modBanque", "modFacture", "modProduct", "modCategorie"), 'FR'=>array('modBlockedLog'));
|
||||
* Note: Example in modTakePos: array('always'=>array("modBanque", "modFacture", "modProduct", "modCategorie"), 'FR'=>array('modBlockedLog'));
|
||||
* Example in modAccounting: array("modFacture", "modBanque", "modTax");
|
||||
|
||||
* @see $requiredby
|
||||
*/
|
||||
public $depends;
|
||||
|
|
@ -381,15 +468,18 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||
public $warnings_unactivation;
|
||||
|
||||
/**
|
||||
* @var array Minimum version of PHP required by module.
|
||||
* @var int[] Minimum version of PHP required by module.
|
||||
* e.g.: PHP ≥ 7.0 = array(7, 0)
|
||||
*/
|
||||
public $phpmin;
|
||||
|
||||
/**
|
||||
* @var int[] Maximum version of PHP ensured compatible with module.
|
||||
*/
|
||||
public $phpmax;
|
||||
|
||||
/**
|
||||
* @var array Minimum version of Dolibarr required by module.
|
||||
* @var int[] Minimum version of Dolibarr required by module.
|
||||
* e.g.: Dolibarr ≥ 3.6 = array(3, 6)
|
||||
*/
|
||||
public $need_dolibarr_version;
|
||||
|
|
@ -1506,7 +1596,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||
*/
|
||||
public function insert_cronjobs()
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT . '/cron/class/cronjob.class.php';
|
||||
|
||||
|
|
@ -1611,7 +1701,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||
return $err;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Removes boxes
|
||||
*
|
||||
|
|
@ -1945,7 +2035,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||
$sql .= ", '".$this->db->escape($r_perms)."'";
|
||||
$sql .= ", '".$this->db->escape($r_subperms)."'";
|
||||
$sql .= ", '".$this->db->escape($r_enabled)."'";
|
||||
$sql.= ")";
|
||||
$sql .= ")";
|
||||
|
||||
$resqlinsert = $this->db->query($sql, 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ class ModeleImports
|
|||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $datatoimport;
|
||||
|
||||
/**
|
||||
|
|
@ -94,16 +97,34 @@ class ModeleImports
|
|||
public $version_lib;
|
||||
|
||||
// Array of all drivers
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $driverlabel = array();
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $driverdesc = array();
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $driverversion = array();
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $drivererror = array();
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $liblabel = array();
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $libversion = array();
|
||||
|
||||
/**
|
||||
|
|
@ -256,7 +277,7 @@ class ModeleImports
|
|||
$file = $dir."/import_".$moduleid.".modules.php";
|
||||
$classname = "Import".ucfirst($moduleid);
|
||||
|
||||
require_once $file;
|
||||
require_once $file;
|
||||
$module = new $classname($db, '');
|
||||
|
||||
// Picto
|
||||
|
|
@ -285,7 +306,7 @@ class ModeleImports
|
|||
*/
|
||||
public function getPictoForKey($key)
|
||||
{
|
||||
return $this->picto[$key];
|
||||
return $this->picto[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -296,7 +317,7 @@ class ModeleImports
|
|||
*/
|
||||
public function getDriverLabelForKey($key)
|
||||
{
|
||||
return $this->driverlabel[$key];
|
||||
return $this->driverlabel[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -307,7 +328,7 @@ class ModeleImports
|
|||
*/
|
||||
public function getDriverDescForKey($key)
|
||||
{
|
||||
return $this->driverdesc[$key];
|
||||
return $this->driverdesc[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -318,7 +339,7 @@ class ModeleImports
|
|||
*/
|
||||
public function getDriverVersionForKey($key)
|
||||
{
|
||||
return $this->driverversion[$key];
|
||||
return $this->driverversion[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -329,7 +350,7 @@ class ModeleImports
|
|||
*/
|
||||
public function getLibLabelForKey($key)
|
||||
{
|
||||
return $this->liblabel[$key];
|
||||
return $this->liblabel[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -340,14 +361,14 @@ class ModeleImports
|
|||
*/
|
||||
public function getLibVersionForKey($key)
|
||||
{
|
||||
return $this->libversion[$key];
|
||||
return $this->libversion[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element from table name with prefix
|
||||
*
|
||||
* @param string $tableNameWithPrefix Table name with prefix
|
||||
* @return string Element name or table element as default
|
||||
* @param string $tableNameWithPrefix Table name with prefix
|
||||
* @return string Element name or table element as default
|
||||
*/
|
||||
public function getElementFromTableWithPrefix($tableNameWithPrefix)
|
||||
{
|
||||
|
|
@ -358,6 +379,114 @@ class ModeleImports
|
|||
$element = self::$mapTableToElement[$tableElement];
|
||||
}
|
||||
|
||||
return $element;
|
||||
return $element;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Open input file
|
||||
*
|
||||
* @param string $file Path of filename
|
||||
* @return int Return integer <0 if KO, >=0 if OK
|
||||
*/
|
||||
public function import_open_file($file)
|
||||
{
|
||||
// phpcs:enable
|
||||
$msg = get_class($this)."::".__FUNCTION__." not implemented";
|
||||
dol_syslog($msg, LOG_ERR);
|
||||
$this->errors[] = $msg;
|
||||
$this->error = $msg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return nb of records. File must be closed.
|
||||
*
|
||||
* @param string $file Path of filename
|
||||
* @return int Return integer <0 if KO, >=0 if OK
|
||||
*/
|
||||
public function import_get_nb_of_lines($file)
|
||||
{
|
||||
// phpcs:enable
|
||||
$msg = get_class($this)."::".__FUNCTION__." not implemented";
|
||||
dol_syslog($msg, LOG_ERR);
|
||||
$this->errors[] = $msg;
|
||||
$this->error = $msg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Input header line from file
|
||||
*
|
||||
* @return int Return integer <0 if KO, >=0 if OK
|
||||
*/
|
||||
public function import_read_header()
|
||||
{
|
||||
// phpcs:enable
|
||||
$msg = get_class($this)."::".__FUNCTION__." not implemented";
|
||||
dol_syslog($msg, LOG_ERR);
|
||||
$this->errors[] = $msg;
|
||||
$this->error = $msg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return array of next record in input file.
|
||||
*
|
||||
* @return array<string,array{val:mixed,type:int<-1,1>}>|boolean Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string)
|
||||
*/
|
||||
public function import_read_record()
|
||||
{
|
||||
// phpcs:enable
|
||||
$msg = get_class($this)."::".__FUNCTION__." not implemented";
|
||||
dol_syslog($msg, LOG_ERR);
|
||||
$this->errors[] = $msg;
|
||||
$this->error = $msg;
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Close file handle
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function import_close_file()
|
||||
{
|
||||
// phpcs:enable
|
||||
$msg = get_class($this)."::".__FUNCTION__." not implemented";
|
||||
dol_syslog($msg, LOG_ERR);
|
||||
$this->errors[] = $msg;
|
||||
$this->error = $msg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Insert a record into database
|
||||
*
|
||||
* @param array<string,array{val:mixed,type:int<-1,1>}>|boolean $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
|
||||
* @param array<string,string> $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]...
|
||||
* @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...)
|
||||
* @param int $maxfields Max number of fields to use
|
||||
* @param string $importid Import key
|
||||
* @param string[] $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor.
|
||||
* @return int Return integer <0 if KO, >0 if OK
|
||||
*/
|
||||
public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys)
|
||||
{
|
||||
// phpcs:enable
|
||||
$msg = get_class($this)."::".__FUNCTION__." not implemented";
|
||||
dol_syslog($msg, LOG_ERR);
|
||||
$this->errors[] = $msg;
|
||||
$this->error = $msg;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
|
||||
*
|
||||
* @param string $action Event action code
|
||||
* @param Object $object Object
|
||||
* @param Adherent|User|UserGroup|Contact $object Object (Note: AdherentType seems excluded)
|
||||
* @param User $user Object user
|
||||
* @param Translate $langs Object langs
|
||||
* @param conf $conf Object conf
|
||||
* @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK
|
||||
* @param Conf $conf Object conf
|
||||
* @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK
|
||||
*/
|
||||
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
|
||||
{
|
||||
|
|
@ -80,6 +80,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
|
||||
// Users
|
||||
if ($action == 'USER_CREATE') {
|
||||
'@phan-var-force User $object'; // Seems to suppose this object kind
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -102,6 +103,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'USER_MODIFY') {
|
||||
'@phan-var-force User $object'; // Seems to suppose this object kind
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -110,7 +112,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
if ($result > 0) {
|
||||
if (empty($object->oldcopy) || !is_object($object->oldcopy)) {
|
||||
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
||||
$object->oldcopy = clone $object;
|
||||
$object->oldcopy = clone $object; // @phan-suppress-current-line PhanTypeMismatchProperty
|
||||
}
|
||||
|
||||
$oldinfo = $object->oldcopy->_load_ldap_info();
|
||||
|
|
@ -181,6 +183,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'USER_NEW_PASSWORD') {
|
||||
'@phan-var-force User $object'; // Seems to suppose this object kind
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -189,7 +192,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
if ($result > 0) {
|
||||
if (empty($object->oldcopy) || !is_object($object->oldcopy)) {
|
||||
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
||||
$object->oldcopy = clone $object;
|
||||
$object->oldcopy = clone $object; // @phan-suppress-current-line PhanTypeMismatchProperty
|
||||
}
|
||||
|
||||
$oldinfo = $object->oldcopy->_load_ldap_info();
|
||||
|
|
@ -214,6 +217,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'USER_ENABLEDISABLE') {
|
||||
'@phan-var-force User $object'; // Seems to suppose this object kind
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalInt("LDAP_SYNCHRO_ACTIVE") === Ldap::SYNCHRO_DOLIBARR_TO_LDAP && getDolGlobalString('LDAP_SERVER_TYPE') == "activedirectory") {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -244,6 +248,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'USER_DELETE') {
|
||||
'@phan-var-force User $object'; // Seems to suppose this object kind
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -261,6 +266,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'USERGROUP_CREATE') {
|
||||
'@phan-var-force UserGroup $object'; // Seems to suppose this object kind
|
||||
// Groups
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
|
|
@ -293,6 +299,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'USERGROUP_MODIFY') {
|
||||
'@phan-var-force UserGroup $object'; // Seems to suppose this object kind
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -326,6 +333,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'USERGROUP_DELETE') {
|
||||
'@phan-var-force UserGroup $object'; // Seems to suppose this object kind
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -343,6 +351,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'CONTACT_CREATE') {
|
||||
'@phan-var-force Contact $object'; // Seems to suppose this object kind
|
||||
// Contacts
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_CONTACT_ACTIVE')) {
|
||||
|
|
@ -361,6 +370,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'CONTACT_MODIFY') {
|
||||
'@phan-var-force Contact $object'; // Seems to suppose this object kind
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_CONTACT_ACTIVE')) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -369,7 +379,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
if ($result > 0) {
|
||||
if (empty($object->oldcopy) || !is_object($object->oldcopy)) {
|
||||
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
||||
$object->oldcopy = clone $object;
|
||||
$object->oldcopy = clone $object; // @phan-suppress-current-line PhanTypeMismatchProperty
|
||||
}
|
||||
|
||||
$oldinfo = $object->oldcopy->_load_ldap_info();
|
||||
|
|
@ -394,6 +404,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'CONTACT_DELETE') {
|
||||
'@phan-var-force Contact $object'; // Seems to suppose this object kind
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_CONTACT_ACTIVE')) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -411,6 +422,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'MEMBER_CREATE') {
|
||||
'@phan-var-force Adherent $object'; // Seems to suppose this object kind
|
||||
// Members
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_MEMBER_ACTIVE') && getDolGlobalInt('LDAP_MEMBER_ACTIVE') == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
|
|
@ -455,6 +467,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'MEMBER_VALIDATE') {
|
||||
'@phan-var-force UserGroup $object'; // Seems to suppose this object kind
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_MEMBER_ACTIVE') && getDolGlobalInt('LDAP_MEMBER_ACTIVE') == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
// If status field is setup to be synchronized
|
||||
|
|
@ -476,6 +489,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'MEMBER_SUBSCRIPTION') {
|
||||
'@phan-var-force Adherent|User $object'; // Seems to suppose this object type
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_MEMBER_ACTIVE') && getDolGlobalInt('LDAP_MEMBER_ACTIVE') == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
// If subscriptions fields are setup to be synchronized
|
||||
|
|
@ -501,6 +515,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'MEMBER_MODIFY') {
|
||||
'@phan-var-force Adherent|User $object'; // Seems to suppose this object type
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_MEMBER_ACTIVE') && getDolGlobalInt('LDAP_MEMBER_ACTIVE') == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -509,7 +524,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
if ($result > 0) {
|
||||
if (empty($object->oldcopy) || !is_object($object->oldcopy)) {
|
||||
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
||||
$object->oldcopy = clone $object;
|
||||
$object->oldcopy = clone $object; // @phan-suppress-current-line PhanTypeMismatchProperty
|
||||
}
|
||||
|
||||
$oldinfo = $object->oldcopy->_load_ldap_info();
|
||||
|
|
@ -589,6 +604,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'MEMBER_NEW_PASSWORD') {
|
||||
'@phan-var-force Adherent|User $object'; // Seems to suppose this object type
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_MEMBER_ACTIVE') && getDolGlobalInt('LDAP_MEMBER_ACTIVE') == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
// If password field is setup to be synchronized
|
||||
|
|
@ -610,6 +626,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'MEMBER_RESILIATE') {
|
||||
'@phan-var-force Adherent|User $object'; // Seems to suppose this object type
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_MEMBER_ACTIVE') && getDolGlobalInt('LDAP_MEMBER_ACTIVE') == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
// If status field is setup to be synchronized
|
||||
|
|
@ -631,6 +648,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'MEMBER_DELETE') {
|
||||
'@phan-var-force Adherent|User $object'; // Seems to suppose this object type
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_MEMBER_ACTIVE') && getDolGlobalInt('LDAP_MEMBER_ACTIVE') == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -678,7 +696,8 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'MEMBER_TYPE_CREATE') {
|
||||
// Members types
|
||||
'@phan-var-force Adherent|User $object'; // Seems to suppose this object type
|
||||
// Member types
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_MEMBER_TYPE_ACTIVE') && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -701,6 +720,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'MEMBER_TYPE_MODIFY') {
|
||||
'@phan-var-force Adherent|User $object'; // Seems to suppose this object type
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (getDolGlobalString('LDAP_MEMBER_TYPE_ACTIVE') && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
|
|
@ -709,7 +729,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
if ($result > 0) {
|
||||
if (empty($object->oldcopy) || !is_object($object->oldcopy)) {
|
||||
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
||||
$object->oldcopy = clone $object;
|
||||
$object->oldcopy = clone $object; // @phan-suppress-current-line PhanTypeMismatchProperty
|
||||
}
|
||||
|
||||
$object->oldcopy->listMembersForMemberType('', 1);
|
||||
|
|
@ -738,7 +758,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
} elseif ($action == 'MEMBER_TYPE_DELETE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
'@phan-var-force Adherent|User $object'; // Seems to suppose this object type
|
||||
if (getDolGlobalString('LDAP_MEMBER_TYPE_ACTIVE') && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connectBind();
|
||||
|
|
|
|||
|
|
@ -456,7 +456,7 @@ class EmailCollector extends CommonObject
|
|||
* @param string $sortorder sorting order
|
||||
* @param int $limit sort limit
|
||||
* @param int $page page to start on
|
||||
* @return array Array with key => EmailCollector object
|
||||
* @return EmailCollector[] Array with key => EmailCollector object
|
||||
*/
|
||||
public function fetchAll(User $user, $activeOnly = 0, $sortfield = 's.rowid', $sortorder = 'ASC', $limit = 100, $page = 0)
|
||||
{
|
||||
|
|
@ -1578,7 +1578,7 @@ class EmailCollector extends CommonObject
|
|||
if ($f) {
|
||||
$folder = $f[0];
|
||||
if ($folder instanceof Webklex\PHPIMAP\Folder) {
|
||||
$Query = $folder->messages()->where($criteria);
|
||||
$Query = $folder->messages()->where($criteria); // @phan-suppress-current-line PhanPluginUnknownObjectMethodCall
|
||||
} else {
|
||||
$error++;
|
||||
$this->error = "Source directory ".$sourcedir." not found";
|
||||
|
|
@ -1605,6 +1605,7 @@ class EmailCollector extends CommonObject
|
|||
return -1;
|
||||
}
|
||||
|
||||
'@phan-var-force Webklex\PHPIMAP\Query\Query $Query';
|
||||
try {
|
||||
//var_dump($Query->count());
|
||||
if ($mode > 0) {
|
||||
|
|
@ -1665,7 +1666,8 @@ class EmailCollector extends CommonObject
|
|||
|
||||
// GET header and overview datas
|
||||
if (getDolGlobalString('MAIN_IMAP_USE_PHPIMAP')) {
|
||||
$header = $imapemail->getHeader()->raw;
|
||||
'@phan-var-force Webklex\PHPIMAP\Message $imapemail';
|
||||
$header = $imapemail->getHeader()->raw; // @phan-suppress-current-line PhanPluginUnknownObjectMethodCall // @phan-suppress-current-line PhanPluginUnknownObjectMethodCall
|
||||
$overview = $imapemail->getAttributes();
|
||||
} else {
|
||||
$header = imap_fetchheader($connection, $imapemail, FT_UID);
|
||||
|
|
@ -1700,6 +1702,7 @@ class EmailCollector extends CommonObject
|
|||
|
||||
if (getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')) {
|
||||
/** @var Webklex\PHPIMAP\Message $imapemail */
|
||||
'@phan-var-force Webklex\PHPIMAP\Message $imapemail';
|
||||
// $operationslog .= " - ".dol_escape_htmltag((string) $imapemail);
|
||||
$msgid = str_replace(array('<', '>'), '', $overview['message_id']);
|
||||
} else {
|
||||
|
|
@ -1853,6 +1856,7 @@ class EmailCollector extends CommonObject
|
|||
|
||||
if (getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')) {
|
||||
/** @var Webklex\PHPIMAP\Message $imapemail */
|
||||
'@phan-var-force Webklex\PHPIMAP\Message $imapemail';
|
||||
if ($imapemail->hasHTMLBody()) {
|
||||
$htmlmsg = $imapemail->getHTMLBody();
|
||||
}
|
||||
|
|
@ -1962,8 +1966,8 @@ class EmailCollector extends CommonObject
|
|||
$sendtocc = empty($overview['cc']) ? '' : $overview['cc'];
|
||||
$sendtobcc = empty($overview['bcc']) ? '' : $overview['bcc'];
|
||||
|
||||
$tmpdate = $overview['date']->toDate();
|
||||
$tmptimezone = $tmpdate->getTimezone()->getName();
|
||||
$tmpdate = $overview['date']->toDate(); // @phan-suppress-current-line PhanPluginUnknownObjectMethodCall
|
||||
$tmptimezone = $tmpdate->getTimezone()->getName(); // @phan-suppress-current-line PhanPluginUnknownObjectMethodCall
|
||||
|
||||
$dateemail = dol_stringtotime((string) $overview['date'], 'gmt'); // if $overview['timezone'] is "+00:00"
|
||||
if (preg_match('/^([+\-])(\d\d):(\d\d)/', $tmptimezone, $reg)) {
|
||||
|
|
@ -3122,6 +3126,7 @@ class EmailCollector extends CommonObject
|
|||
|
||||
$result = dol_include_once($reldir."core/modules/project/".$modele.'.php');
|
||||
$modModuleToUseForNextValue = new $classname();
|
||||
'@phan-var-force ModeleNumRefProjects $modModuleToUseForNextValue';
|
||||
$defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $projecttocreate);
|
||||
}
|
||||
$projecttocreate->ref = $defaultref;
|
||||
|
|
@ -3262,6 +3267,7 @@ class EmailCollector extends CommonObject
|
|||
|
||||
$result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php');
|
||||
$modModuleToUseForNextValue = new $classname();
|
||||
'@phan-var-force ModeleNumRefTicket $modModuleToUseForNextValue';
|
||||
$defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate);
|
||||
}
|
||||
$tickettocreate->ref = $defaultref;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2020 Ahmad Jamaly Rabib <rabib@metroworks.co.jp>
|
||||
* Copyright (C) 2021-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -50,88 +51,97 @@ class Import
|
|||
public $errno;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<array{position_of_profile:string,module:DolibarrModules}>
|
||||
*/
|
||||
public $array_import_module;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var int[]
|
||||
*/
|
||||
public $array_import_perms;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
public $array_import_icon;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
public $array_import_code;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
public $array_import_label;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<string[]>
|
||||
*/
|
||||
public $array_import_tables;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<''|array<string,string>>
|
||||
*/
|
||||
public $array_import_tables_creator;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<array<string,string>>
|
||||
*/
|
||||
public $array_import_fields;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<''|array<string,string>>
|
||||
*/
|
||||
public $array_import_fieldshidden;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<''|array<string,string>>
|
||||
*/
|
||||
public $array_import_entities;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<''|array<string,string>>
|
||||
*/
|
||||
public $array_import_regex;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<''|array<string,string>>
|
||||
*/
|
||||
public $array_import_updatekeys;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<''|array<string,string>>
|
||||
*/
|
||||
public $array_import_preselected_updatekeys;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<''|array<string,string>>
|
||||
*/
|
||||
public $array_import_examplevalues;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<''|array<array{rule:string,file:string,class:string,method:string}>>
|
||||
*/
|
||||
public $array_import_convertvalue;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<''|array<string,string>>
|
||||
*/
|
||||
public $array_import_run_sql_after;
|
||||
|
||||
// To store import templates
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $hexa; // List of fields in the export profile
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $datatoimport;
|
||||
|
||||
/**
|
||||
|
|
@ -211,9 +221,10 @@ class Import
|
|||
$classname = $modulename;
|
||||
require_once $file;
|
||||
$module = new $classname($this->db);
|
||||
'@phan-var-force DolibarrModules $module';
|
||||
|
||||
if (isset($module->import_code) && is_array($module->import_code)) {
|
||||
foreach ($module->import_code as $r => $value) {
|
||||
foreach ($module->import_code as $r => $value) { // @phan-suppress-current-line PhanTypeMismatchForeach
|
||||
if ($filter && ($filter != $module->import_code[$r])) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -257,13 +268,14 @@ class Import
|
|||
$this->array_import_fields[$i] = $module->import_fields_array[$r];
|
||||
// Array of hidden fields to import (key=field, value=label)
|
||||
$this->array_import_fieldshidden[$i] = (isset($module->import_fieldshidden_array[$r]) ? $module->import_fieldshidden_array[$r] : '');
|
||||
// Array of entiteis to export (key=field, value=entity)
|
||||
// Array of entities to export (key=field, value=entity)
|
||||
$this->array_import_entities[$i] = $module->import_entities_array[$r];
|
||||
// Array of aliases to export (key=field, value=alias)
|
||||
$this->array_import_regex[$i] = (isset($module->import_regex_array[$r]) ? $module->import_regex_array[$r] : '');
|
||||
// Array of columns allowed as UPDATE options
|
||||
$this->array_import_updatekeys[$i] = (isset($module->import_updatekeys_array[$r]) ? $module->import_updatekeys_array[$r] : '');
|
||||
// Array of columns preselected as UPDATE options
|
||||
// import_preselected_updatekeys_array does not exist - backward compatibility ? @phan-suppress-next-line PhanUndeclaredProperty
|
||||
$this->array_import_preselected_updatekeys[$i] = (isset($module->import_preselected_updatekeys_array[$r]) ? $module->import_preselected_updatekeys_array[$r] : '');
|
||||
// Array of examples
|
||||
$this->array_import_examplevalues[$i] = (isset($module->import_examplevalues_array[$r]) ? $module->import_examplevalues_array[$r] : '');
|
||||
|
|
@ -272,7 +284,7 @@ class Import
|
|||
// Sql request to run after import
|
||||
$this->array_import_run_sql_after[$i] = (isset($module->import_run_sql_after_array[$r]) ? $module->import_run_sql_after_array[$r] : '');
|
||||
// Module
|
||||
$this->array_import_module[$i] = array('position_of_profile'=>($module->module_position.'-'.$module->import_code[$r]), 'module'=>$module);
|
||||
$this->array_import_module[$i] = array('position_of_profile' => ($module->module_position.'-'.$module->import_code[$r]), 'module' => $module);
|
||||
|
||||
dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->import_code[$r].", nb of fields=".count($module->import_fields_array[$r]));
|
||||
$i++;
|
||||
|
|
@ -312,6 +324,7 @@ class Import
|
|||
$classname = "Import".$model;
|
||||
require_once $dir.$file;
|
||||
$objmodel = new $classname($this->db, $datatoimport);
|
||||
'@phan-var-force CommonObject $objmodel';
|
||||
|
||||
$outputlangs = $langs; // Lang for output
|
||||
$s = '';
|
||||
|
|
@ -420,8 +433,8 @@ class Import
|
|||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
* @param User $user User that delete
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @param User $user User that delete
|
||||
* @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int Return integer <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete($user, $notrigger = 0)
|
||||
|
|
|
|||
|
|
@ -753,6 +753,7 @@ if ($step == 4 && $datatoimport) {
|
|||
|
||||
// The separator has been defined, if it is a unique char, we check it is valid by reading the source file
|
||||
if ($model == 'csv' && strlen($separator) == 1 && !GETPOSTISSET('separator')) {
|
||||
'@phan-var-force ImportCsv $obj';
|
||||
// Count the char in first line of file.
|
||||
$fh = fopen($conf->import->dir_temp.'/'.$filetoimport, 'r');
|
||||
if ($fh) {
|
||||
|
|
@ -781,12 +782,15 @@ if ($step == 4 && $datatoimport) {
|
|||
$classname = "Import".ucfirst($model);
|
||||
require_once $dir.$file;
|
||||
$obj = new $classname($db, $datatoimport);
|
||||
'@phan-var-force ModeleImports $obj';
|
||||
if ($model == 'csv') {
|
||||
'@phan-var-force ImportCsv $obj';
|
||||
$obj->separator = $separator_used;
|
||||
$obj->enclosure = $enclosure;
|
||||
$obj->charset = '';
|
||||
}
|
||||
if ($model == 'xlsx') {
|
||||
'@phan-var-force ImportXlsx $obj';
|
||||
if (!preg_match('/\.xlsx$/i', $filetoimport)) {
|
||||
$langs->load("errors");
|
||||
$param = '&datatoimport='.$datatoimport.'&format='.$format;
|
||||
|
|
@ -803,7 +807,7 @@ if ($step == 4 && $datatoimport) {
|
|||
// Load the source fields from input file into variable $arrayrecord
|
||||
$fieldssource = array();
|
||||
/** @var array<string,string> $fieldssource */
|
||||
$result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport, $langs);
|
||||
$result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport);
|
||||
if ($result >= 0) {
|
||||
// Read first line
|
||||
$arrayrecord = $obj->import_read_record();
|
||||
|
|
@ -970,6 +974,7 @@ if ($step == 4 && $datatoimport) {
|
|||
|
||||
// Separator and enclosure
|
||||
if ($model == 'csv') {
|
||||
'@phan-var-force ImportCsv $obj';
|
||||
print '<tr><td>'.$langs->trans("CsvOptions").'</td>';
|
||||
print '<td>';
|
||||
print '<form method="POST">';
|
||||
|
|
@ -1130,6 +1135,7 @@ if ($step == 4 && $datatoimport) {
|
|||
break;
|
||||
}*/
|
||||
print '<tr style="height:'.$height.'" class="trimport oddevenimport">';
|
||||
// Note: $code is int, but index should be fieldname? -> @phan-suppress-next-line PhanTypeMismatchDimFetch
|
||||
$entity = (!empty($objimport->array_import_entities[0][$code]) ? $objimport->array_import_entities[0][$code] : $objimport->array_import_icon[0]);
|
||||
|
||||
$entityicon = !empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ...
|
||||
|
|
@ -1545,14 +1551,16 @@ if ($step == 5 && $datatoimport) {
|
|||
$classname = "Import".ucfirst($model);
|
||||
require_once $dir.$file;
|
||||
$obj = new $classname($db, $datatoimport);
|
||||
'@phan-var-force ModeleImports $obj';
|
||||
if ($model == 'csv') {
|
||||
'@phan-var-force ImportCsv $obj';
|
||||
$obj->separator = $separator_used;
|
||||
$obj->enclosure = $enclosure;
|
||||
}
|
||||
|
||||
// Load source fields in input file
|
||||
$fieldssource = array();
|
||||
$result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport, $langs);
|
||||
$result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport);
|
||||
|
||||
if ($result >= 0) {
|
||||
// Read first line
|
||||
|
|
@ -1636,6 +1644,7 @@ if ($step == 5 && $datatoimport) {
|
|||
|
||||
// Separator and enclosure
|
||||
if ($model == 'csv') {
|
||||
'@phan-var-force ImportCsv $obj';
|
||||
print '<tr><td>'.$langs->trans("CsvOptions").'</td>';
|
||||
print '<td>';
|
||||
print $langs->trans("Separator").' : '.dol_escape_htmltag($separator);
|
||||
|
|
@ -1839,7 +1848,7 @@ if ($step == 5 && $datatoimport) {
|
|||
// Open input file
|
||||
$nbok = 0;
|
||||
$pathfile = $conf->import->dir_temp.'/'.$filetoimport;
|
||||
$result = $obj->import_open_file($pathfile, $langs);
|
||||
$result = $obj->import_open_file($pathfile);
|
||||
if ($result > 0) {
|
||||
global $tablewithentity_cache;
|
||||
$tablewithentity_cache = array();
|
||||
|
|
@ -2036,14 +2045,16 @@ if ($step == 6 && $datatoimport) {
|
|||
$classname = "Import".ucfirst($model);
|
||||
require_once $dir.$file;
|
||||
$obj = new $classname($db, $datatoimport);
|
||||
'@phan-var-force ModeleImports $obj';
|
||||
if ($model == 'csv') {
|
||||
'@phan-var-force ImportCsv $obj';
|
||||
$obj->separator = $separator_used;
|
||||
$obj->enclosure = $enclosure;
|
||||
}
|
||||
|
||||
// Load source fields in input file
|
||||
$fieldssource = array();
|
||||
$result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport, $langs);
|
||||
$result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport);
|
||||
if ($result >= 0) {
|
||||
// Read first line
|
||||
$arrayrecord = $obj->import_read_record();
|
||||
|
|
@ -2122,6 +2133,7 @@ if ($step == 6 && $datatoimport) {
|
|||
|
||||
// Separator and enclosure
|
||||
if ($model == 'csv') {
|
||||
'@phan-var-force ImportCsv $obj';
|
||||
print '<tr><td>'.$langs->trans("CsvOptions").'</td>';
|
||||
print '<td>';
|
||||
print $langs->trans("Separator").' : ';
|
||||
|
|
@ -2253,7 +2265,7 @@ if ($step == 6 && $datatoimport) {
|
|||
// Open input file
|
||||
$nbok = 0;
|
||||
$pathfile = $conf->import->dir_temp.'/'.$filetoimport;
|
||||
$result = $obj->import_open_file($pathfile, $langs);
|
||||
$result = $obj->import_open_file($pathfile);
|
||||
if ($result > 0) {
|
||||
global $tablewithentity_cache;
|
||||
$tablewithentity_cache = array();
|
||||
|
|
|
|||
Loading…
Reference in a new issue