Fix: Fix tons of bugs after change for new way to declare modules

features
This commit is contained in:
Laurent Destailleur 2012-03-01 00:03:16 +01:00
parent e0f7637bb3
commit badc6d0f45
5 changed files with 190 additions and 109 deletions

View File

@ -63,6 +63,7 @@ class Conf
public $sms_engine_modules = array();
public $barcode_modules = array();
public $substitutions_modules = array();
public $societe_modules = array();
var $logbuffer = array();
@ -164,9 +165,8 @@ class Conf
if (! is_array($this->$varname)) { $this->$varname = array(); }
$arrValue = @unserialize($value);
if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue;
else if ($partname == 'barcode') $value = '/'.$modulename.'/core/modules/'.$partname.'/';
else if ($partname == 'models') $value = $modulename.'/';
else $value = ($value == 1 ? '/'.$modulename.'/core/'.$partname.'/' : $value);
else if (in_array($partname,array('login','menus','triggers'))) $value = '/'.$modulename.'/core/'.$partname.'/';
else if ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/';
$this->$varname = array_merge($this->$varname, array($modulename => $value));
}
// If this is a module constant (must be at end)

View File

@ -218,6 +218,9 @@ dol_fiche_head($head, 'general', $langs->trans("ThirdParty"), 0, 'company');
dol_htmloutput_mesg($mesg);
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
// Module to manage customer/supplier code
print_titre($langs->trans("CompanyCodeChecker"));
@ -232,9 +235,10 @@ print ' <td align="center" width="60">'.$langs->trans("Infos").'</td>';
print "</tr>\n";
$var = true;
foreach ($conf->file->dol_document_root as $dirroot)
foreach ($dirsociete as $dirroot)
{
$dir = $dirroot . "/core/modules/societe/";
$dir = dol_buildpath($dirroot,0);
$handle = @opendir($dir);
if (is_resource($handle))
{
@ -246,7 +250,7 @@ foreach ($conf->file->dol_document_root as $dirroot)
$file = substr($file, 0, dol_strlen($file)-4);
try {
dol_include_once("/core/modules/societe/".$file.".php");
dol_include_once($dirroot.$file.".php");
}
catch(Exception $e)
{
@ -312,11 +316,11 @@ print '<td align="center" width="80">'.$langs->trans("Status").'</td>';
print '<td align="center" width="60">&nbsp;</td>';
print "</tr>\n";
$var = true;
foreach ($conf->file->dol_document_root as $dirroot)
foreach ($dirsociete as $dirroot)
{
$dir = $dirroot . "/core/modules/societe/";
$handle = @opendir($dir);
$dir = dol_buildpath($dirroot,0);
$handle = @opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
@ -325,7 +329,13 @@ foreach ($conf->file->dol_document_root as $dirroot)
{
$file = substr($file, 0, dol_strlen($file)-4);
dol_include_once("/core/modules/societe/".$file.".php");
try {
dol_include_once($dirroot.$file.".php");
}
catch(Exception $e)
{
dol_syslog($e->getMessage(), LOG_ERR);
}
$modCodeCompta = new $file;
$var = !$var;
@ -398,101 +408,104 @@ print '<td align="center" width="80">'.$langs->trans("Status").'</td>';
print '<td align="center" width="60">'.$langs->trans("Infos").'</td>';
print "</tr>\n";
$var=true;
foreach ($conf->file->dol_document_root as $dirroot)
foreach ($dirsociete as $dirroot)
{
$dir = $dirroot . "/core/modules/societe/doc";
$dir = dol_buildpath($dirroot.'doc/',0);
if (is_dir($dir))
$handle=@opendir($dir);
if (is_resource($handle))
{
$handle=opendir($dir);
if (is_resource($handle))
while (($file = readdir($handle))!==false)
{
while (($file = readdir($handle))!==false)
if (preg_match('/\.modules\.php$/i',$file))
{
if (preg_match('/\.modules\.php$/i',$file))
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
try {
dol_include_once($dirroot.'doc/'.$file);
}
catch(Exception $e)
{
dol_syslog($e->getMessage(), LOG_ERR);
}
$module = new $classname($db);
$modulequalified=1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
if ($modulequalified)
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
$var = !$var;
print '<tr '.$bc[$var].'><td width="100">';
print $module->name;
print "</td><td>\n";
if (method_exists($module,'info')) print $module->info($langs);
else print $module->description;
print '</td>';
require_once($dir.'/'.$file);
$module = new $classname($db);
$modulequalified=1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
if ($modulequalified)
// Activate / Disable
if (in_array($name, $def))
{
$var = !$var;
print '<tr '.$bc[$var].'><td width="100">';
print $module->name;
print "</td><td>\n";
if (method_exists($module,'info')) print $module->info($langs);
else print $module->description;
print '</td>';
// Activate / Disable
if (in_array($name, $def))
print "<td align=\"center\">\n";
//if ($conf->global->COMPANY_ADDON_PDF != "$name")
//{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"),'switch_on');
print '</a>';
//}
//else
//{
// print img_picto($langs->trans("Enabled"),'on');
//}
print "</td>";
}
else
{
if (versioncompare($module->phpmin,versionphparray()) > 0)
{
print "<td align=\"center\">\n";
//if ($conf->global->COMPANY_ADDON_PDF != "$name")
//{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"),'switch_on');
print '</a>';
//}
//else
//{
// print img_picto($langs->trans("Enabled"),'on');
//}
print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'switch_off');
print "</td>";
}
else
{
if (versioncompare($module->phpmin,versionphparray()) > 0)
{
print "<td align=\"center\">\n";
print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'switch_off');
print "</td>";
}
else
{
print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>";
}
print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>";
}
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
if ($modele->type == 'pdf')
{
$htmltooltip.='<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
}
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraft").': '.yn($module->option_draft_watermark,1,1);
print '<td align="center" nowrap="nowrap">';
if ($modele->type == 'pdf')
{
$linkspec='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
}
else
{
$linkspec=img_object($langs->trans("PreviewNotAvailable"),'generic');
}
print $form->textwithpicto(' &nbsp; '.$linkspec,$htmltooltip,1,0);
print '</td>';
print "</tr>\n";
}
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
if ($modele->type == 'pdf')
{
$htmltooltip.='<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
}
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraft").': '.yn($module->option_draft_watermark,1,1);
print '<td align="center" nowrap="nowrap">';
if ($modele->type == 'pdf')
{
$linkspec='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
}
else
{
$linkspec=img_object($langs->trans("PreviewNotAvailable"),'generic');
}
print $form->textwithpicto(' &nbsp; '.$linkspec,$htmltooltip,1,0);
print '</td>';
print "</tr>\n";
}
}
closedir($handle);
}
closedir($handle);
}
}
print '</table>';

View File

@ -438,7 +438,12 @@ abstract class ActionsCardCommon
{
$module = substr($module, 0, dol_strlen($module)-4);
}
require_once(DOL_DOCUMENT_ROOT ."/core/modules/societe/".$module.".php");
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$module.".php");
if ($res) break;
}
$modCodeClient = new $module;
$this->tpl['auto_customercode'] = $modCodeClient->code_auto;
// We verified if the tag prefix is used
@ -470,7 +475,12 @@ abstract class ActionsCardCommon
{
$module = substr($module, 0, dol_strlen($module)-4);
}
require_once(DOL_DOCUMENT_ROOT ."/core/modules/societe/".$module.".php");
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$module.".php");
if ($res) break;
}
$modCodeFournisseur = new $module;
$this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
// We verified if the tag prefix is used

View File

@ -1658,15 +1658,21 @@ class Societe extends CommonObject
}
/**
* \brief Attribut un code client a partir du module de controle des codes.
* \return code_client Code client automatique
* Attribut un code client a partir du module de controle des codes.
*
* @return code_client Code client automatique
*/
function get_codeclient($objsoc=0,$type=0)
{
global $conf;
if ($conf->global->SOCIETE_CODECLIENT_ADDON)
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/societe/'.$conf->global->SOCIETE_CODECLIENT_ADDON.'.php';
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$conf->global->SOCIETE_CODECLIENT_ADDON.".php");
if ($res) break;
}
$var = $conf->global->SOCIETE_CODECLIENT_ADDON;
$mod = new $var;
@ -1678,15 +1684,21 @@ class Societe extends CommonObject
}
/**
* \brief Attribut un code fournisseur a partir du module de controle des codes.
* \return code_fournisseur Code fournisseur automatique
* Attribut un code fournisseur a partir du module de controle des codes.
*
* @return code_fournisseur Code fournisseur automatique
*/
function get_codefournisseur($objsoc=0,$type=1)
{
global $conf;
if ($conf->global->SOCIETE_CODEFOURNISSEUR_ADDON)
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/societe/'.$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON.'.php';
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$conf->global->SOCIETE_FOURNISSEUR_ADDON.".php");
if ($res) break;
}
$var = $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
$mod = new $var;
@ -1706,7 +1718,12 @@ class Societe extends CommonObject
global $conf;
if ($conf->global->SOCIETE_CODECLIENT_ADDON)
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/societe/'.$conf->global->SOCIETE_CODECLIENT_ADDON.'.php';
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$conf->global->SOCIETE_CODECLIENT_ADDON.".php");
if ($res) break;
}
$var = $conf->global->SOCIETE_CODECLIENT_ADDON;
@ -1734,7 +1751,12 @@ class Societe extends CommonObject
global $conf;
if ($conf->global->SOCIETE_CODEFOURNISSEUR_ADDON)
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/societe/'.$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON.'.php';
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON.".php");
if ($res) break;
}
$var = $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
@ -1766,7 +1788,12 @@ class Societe extends CommonObject
global $conf;
if ($conf->global->SOCIETE_CODECLIENT_ADDON)
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/societe/'.$conf->global->SOCIETE_CODECLIENT_ADDON.'.php';
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$conf->global->SOCIETE_CODECLIENT_ADDON.".php");
if ($res) break;
}
$var = $conf->global->SOCIETE_CODECLIENT_ADDON;
@ -1795,7 +1822,12 @@ class Societe extends CommonObject
global $conf;
if ($conf->global->SOCIETE_CODEFOURNISSEUR_ADDON)
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/societe/'.$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON.'.php';
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON.".php");
if ($res) break;
}
$var = $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
@ -1824,7 +1856,12 @@ class Societe extends CommonObject
if ($conf->global->SOCIETE_CODECOMPTA_ADDON)
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/societe/'.$conf->global->SOCIETE_CODECOMPTA_ADDON.'.php';
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.".php");
if ($res) break;
}
$var = $conf->global->SOCIETE_CODECOMPTA_ADDON;

View File

@ -499,7 +499,12 @@ else
{
$module = substr($module, 0, dol_strlen($module)-4);
}
require_once(DOL_DOCUMENT_ROOT ."/core/modules/societe/".$module.".php");
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$module.".php");
if ($res) break;
}
$modCodeClient = new $module;
$module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
@ -507,7 +512,12 @@ else
{
$module = substr($module, 0, dol_strlen($module)-4);
}
require_once(DOL_DOCUMENT_ROOT ."/core/modules/societe/".$module.".php");
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$module.".php");
if ($res) break;
}
$modCodeFournisseur = new $module;
//if ($_GET["type"]=='cp') { $object->client=3; }
@ -693,10 +703,11 @@ else
// Prospect/Customer
print '<tr><td width="25%"><span class="fieldrequired">'.$langs->trans('ProspectCustomer').'</span></td><td width="25%"><select class="flat" name="client">';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2"'.($object->client==2?' selected="selected"':'').'>'.$langs->trans('Prospect').'</option>';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="3"'.($object->client==3?' selected="selected"':'').'>'.$langs->trans('ProspectCustomer').'</option>';
print '<option value="1"'.($object->client==1?' selected="selected"':'').'>'.$langs->trans('Customer').'</option>';
print '<option value="0"'.($object->client==0?' selected="selected"':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
$selected=isset($_POST['client'])?GETPOST('client'):$object->client;
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2"'.($selected==2?' selected="selected"':'').'>'.$langs->trans('Prospect').'</option>';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="3"'.($selected==3?' selected="selected"':'').'>'.$langs->trans('ProspectCustomer').'</option>';
print '<option value="1"'.($selected==1?' selected="selected"':'').'>'.$langs->trans('Customer').'</option>';
print '<option value="0"'.($selected==0?' selected="selected"':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
print '</select></td>';
print '<td width="25%">'.$langs->trans('CustomerCode').'</td><td width="25%">';
@ -716,7 +727,7 @@ else
// Supplier
print '<tr>';
print '<td><span class="fieldrequired">'.$langs->trans('Supplier').'</span></td><td>';
print $form->selectyesno("fournisseur",$object->fournisseur,1);
print $form->selectyesno("fournisseur",(isset($_POST['fournisseur'])?GETPOST('fournisseur'):$object->fournisseur),1);
print '</td>';
print '<td>'.$langs->trans('SupplierCode').'</td><td>';
print '<table class="nobordernopadding"><tr><td>';
@ -991,7 +1002,12 @@ else
{
$module = substr($module, 0, dol_strlen($module)-4);
}
require_once(DOL_DOCUMENT_ROOT ."/core/modules/societe/".$module.".php");
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$module.".php");
if ($res) break;
}
$modCodeClient = new $module;
// We verified if the tag prefix is used
if ($modCodeClient->code_auto)
@ -1004,7 +1020,12 @@ else
{
$module = substr($module, 0, dol_strlen($module)-4);
}
require_once(DOL_DOCUMENT_ROOT ."/core/modules/societe/".$module.".php");
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
foreach ($dirsociete as $dirroot)
{
$res=dol_include_once($dirroot.$module.".php");
if ($res) break;
}
$modCodeFournisseur = new $module;
// On verifie si la balise prefix est utilisee
if ($modCodeFournisseur->code_auto)