Merge pull request #3470 from GPCsolutions/develop-3440

Fix #3440 Only search for core modules in main path
This commit is contained in:
Laurent Destailleur 2015-09-09 20:53:25 +02:00
commit 41803cd868
4 changed files with 31 additions and 142 deletions

View File

@ -1,11 +1,12 @@
<?php <?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -28,6 +29,7 @@
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
$langs->load("errors"); $langs->load("errors");
$langs->load("admin"); $langs->load("admin");
@ -76,28 +78,7 @@ llxHeader('',$langs->trans("Setup"),$help_url);
// Search modules dirs // Search modules dirs
$modulesdir = array(); $modulesdir = dolGetModulesDirs();
foreach ($conf->file->dol_document_root as $type => $dirroot)
{
$modulesdir[$dirroot . '/core/modules/'] = $dirroot . '/core/modules/';
$handle=@opendir($dirroot);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
{
if (is_dir($dirroot . '/' . $file . '/core/modules/'))
{
$modulesdir[$dirroot . '/' . $file . '/core/modules/'] = $dirroot . '/' . $file . '/core/modules/';
}
}
}
closedir($handle);
}
}
//var_dump($modulesdir);
$filename = array(); $filename = array();

View File

@ -1,7 +1,8 @@
<?php <?php
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org> * Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -23,6 +24,7 @@
* \brief Library of admin functions * \brief Library of admin functions
*/ */
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
/** /**
* Renvoi une version en chaine depuis une version en tableau * Renvoi une version en chaine depuis une version en tableau
@ -676,29 +678,7 @@ function activateModule($value,$withdeps=1)
$ret=''; $ret='';
$modName = $value; $modName = $value;
$modFile = $modName . ".class.php"; $modFile = $modName . ".class.php";
$modulesdir = dolGetModulesDirs();
// Loop on each directory to fill $modulesdir
$modulesdir = array();
foreach ($conf->file->dol_document_root as $type => $dirroot)
{
$modulesdir[] = $dirroot."/core/modules/";
$handle=@opendir(dol_osencode($dirroot));
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
{
if (is_dir($dirroot . '/' . $file . '/core/modules/'))
{
$modulesdir[] = $dirroot . '/' . $file . '/core/modules/';
}
}
}
closedir($handle);
}
}
// Loop on each directory // Loop on each directory
$found=false; $found=false;
@ -795,29 +775,7 @@ function unActivateModule($value, $requiredby=1)
$ret=''; $ret='';
$modName = $value; $modName = $value;
$modFile = $modName . ".class.php"; $modFile = $modName . ".class.php";
$modulesdir = dolGetModulesDirs();
// Loop on each directory to fill $modulesdir
$modulesdir = array();
foreach ($conf->file->dol_document_root as $type => $dirroot)
{
$modulesdir[] = $dirroot."/core/modules/";
$handle=@opendir(dol_osencode($dirroot));
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
{
if (is_dir($dirroot . '/' . $file . '/core/modules/'))
{
$modulesdir[] = $dirroot . '/' . $file . '/core/modules/';
}
}
}
closedir($handle);
}
}
// Loop on each directory // Loop on each directory
$found=false; $found=false;
@ -884,36 +842,10 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql
global $db, $modules, $conf, $langs; global $db, $modules, $conf, $langs;
// Search modules // Search modules
$filename = array(); $modulesdir = dolGetModulesDirs();
$modules = array();
$orders = array();
$categ = array();
$dirmod = array();
$modulesdir = array();
$i = 0; // is a sequencer of modules found $i = 0; // is a sequencer of modules found
$j = 0; // j is module number. Automatically affected if module number not defined. $j = 0; // j is module number. Automatically affected if module number not defined.
foreach ($conf->file->dol_document_root as $type => $dirroot)
{
$modulesdir[$dirroot . '/core/modules/'] = $dirroot . '/core/modules/';
$handle=@opendir($dirroot);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
{
if (is_dir($dirroot . '/' . $file . '/core/modules/'))
{
$modulesdir[$dirroot . '/' . $file . '/core/modules/'] = $dirroot . '/' . $file . '/core/modules/';
}
}
}
closedir($handle);
}
}
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir)
{ {
// Load modules attributes in arrays (name, numero, orders) from dir directory // Load modules attributes in arrays (name, numero, orders) from dir directory
@ -963,14 +895,6 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql
} }
} }
$modules[$i] = $objMod;
$filename[$i]= $modName;
$orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module
//print "x".$modName." ".$orders[$i]."\n<br>";
if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories
else $categ[$objMod->special]=1;
$dirmod[$i] = $dirroot;
// Complete arrays // Complete arrays
//&$tabname,&$tablib,&$tabsql,&$tabsqlsort,&$tabfield,&$tabfieldvalue,&$tabfieldinsert,&$tabrowid,&$tabcond //&$tabname,&$tablib,&$tabsql,&$tabsqlsort,&$tabfield,&$tabfieldvalue,&$tabfieldinsert,&$tabrowid,&$tabcond
if (empty($objMod->dictionaries) && ! empty($objMod->dictionnaries)) $objMod->dictionaries=$objMod->dictionnaries; // For backward compatibility if (empty($objMod->dictionaries) && ! empty($objMod->dictionnaries)) $objMod->dictionaries=$objMod->dictionnaries; // For backward compatibility

View File

@ -1,9 +1,10 @@
<?php <?php
/* Copyright (C) 2008-2014 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2008-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -104,7 +105,9 @@ function dolGetModulesDirs($subdir='')
foreach ($conf->file->dol_document_root as $type => $dirroot) foreach ($conf->file->dol_document_root as $type => $dirroot)
{ {
// Default core/modules dir // Default core/modules dir
$modulesdir[$dirroot . '/core/modules'.$subdir.'/'] = $dirroot . '/core/modules'.$subdir.'/'; if ($type === 'main') {
$modulesdir[$dirroot . '/core/modules' . $subdir . '/'] = $dirroot . '/core/modules' . $subdir . '/';
}
// Scan dir from external modules // Scan dir from external modules
$handle=@opendir($dirroot); $handle=@opendir($dirroot);

View File

@ -1,7 +1,8 @@
<?php <?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -28,6 +29,7 @@ define("NOLOGIN",1); // This means this output page does not require to be logge
define("NOCSRFCHECK",1); // We accept to go on this page from external web site. define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require '../../main.inc.php'; require '../../main.inc.php';
require_once '../../core/lib/functions2.lib.php';
$langs->load("main"); $langs->load("main");
$langs->load("install"); $langs->load("install");
@ -99,28 +101,7 @@ $dirlist=$conf->file->dol_document_root;
// Search modules dirs // Search modules dirs
$modulesdir = array(); $modulesdir = dolGetModulesDirs();
foreach ($conf->file->dol_document_root as $type => $dirroot)
{
$modulesdir[$dirroot . '/core/modules/'] = $dirroot . '/core/modules/';
$handle=@opendir($dirroot);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
{
if (is_dir($dirroot . '/' . $file . '/core/modules/'))
{
$modulesdir[$dirroot . '/' . $file . '/core/modules/'] = $dirroot . '/' . $file . '/core/modules/';
}
}
}
closedir($handle);
}
}
//var_dump($modulesdir);
$filename = array(); $filename = array();