2
0
forked from Wavyzz/dolibarr

Qual: Mutualize code

This commit is contained in:
Laurent Destailleur
2008-12-07 20:10:59 +00:00
parent 8b263e4b16
commit 7e0fbd02a1
5 changed files with 103 additions and 267 deletions

View File

@@ -194,57 +194,13 @@ class modMyModule extends DolibarrModules
/**
* \brief Create tables and keys required by module
* Files mymodule.sql and mymodule.key.sql with create table and create keys
* commands must be stored in directory /mysql/tables/mymodule/.
* commands must be stored in directory /mymodule/sql/
* This function is called by this->init.
* \return int <=0 if KO, >0 if OK
*/
function load_tables()
{
include_once(DOL_DOCUMENT_ROOT ."/lib/admin.lib.php");
global $db;
$ok = 1;
if ($ok)
{
$dir = DOL_DOCUMENT_ROOT.'/mymodule/sql/';
$ok = 0;
// Run llx_mytable.sql files
$handle=opendir($dir);
if ($hanlde)
{
while (($file = readdir($handle))!==false)
{
if (eregi('\.sql$',$file) && substr($file,0,4) == 'llx_' && substr($file, -8) <> '.key.sql')
{
$result=run_sql($dir.$file,1);
}
}
closedir($handle);
}
// Run llx_mytable.key.sql files
if ($hanlde)
{
$handle=opendir($dir);
while (($file = readdir($handle))!==false)
{
if (eregi('\.sql$',$file) && substr($file,0,4) == 'llx_' && substr($file, -8) == '.key.sql')
{
$result=run_sql($dir.$file,1);
}
}
closedir($handle);
}
if ($error == 0)
{
$ok = 1;
}
}
return $ok;
return $this->_load_tables('/mymodule/sql/');
}
}