forked from Wavyzz/dolibarr
Debug modulebuilder
This commit is contained in:
@@ -144,6 +144,8 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='')
|
|||||||
if (empty($objectname)) return -1;
|
if (empty($objectname)) return -1;
|
||||||
if (empty($readdir)) $readdir=$destdir;
|
if (empty($readdir)) $readdir=$destdir;
|
||||||
|
|
||||||
|
$pathoffiletoclasssrc=$readdir.'/class/'.strtolower($objectname).'.class.php';
|
||||||
|
|
||||||
// Edit .sql file
|
// Edit .sql file
|
||||||
$pathoffiletoeditsrc=$readdir.'/sql/llx_'.strtolower($objectname).'.sql';
|
$pathoffiletoeditsrc=$readdir.'/sql/llx_'.strtolower($objectname).'.sql';
|
||||||
$pathoffiletoedittarget=$destdir.'/sql/llx_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
|
$pathoffiletoedittarget=$destdir.'/sql/llx_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
|
||||||
@@ -156,7 +158,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='')
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
include_once $pathoffiletoeditsrc;
|
include_once $pathoffiletoclasssrc;
|
||||||
if (class_exists($objectname)) $object=new $objectname($db);
|
if (class_exists($objectname)) $object=new $objectname($db);
|
||||||
else return -1;
|
else return -1;
|
||||||
}
|
}
|
||||||
@@ -168,7 +170,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='')
|
|||||||
// Backup old file
|
// Backup old file
|
||||||
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
|
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
|
||||||
|
|
||||||
$contentsql = file_get_contents(dol_os_encode($pathoffiletoeditsrc), 'r');
|
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
$texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n";
|
$texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n";
|
||||||
@@ -197,7 +199,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='')
|
|||||||
$pathoffiletoeditsrc=$destdir.'/sql/llx_'.strtolower($objectname).'.key.sql';
|
$pathoffiletoeditsrc=$destdir.'/sql/llx_'.strtolower($objectname).'.key.sql';
|
||||||
$pathoffiletoedittarget=$destdir.'/sql/llx_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : '');
|
$pathoffiletoedittarget=$destdir.'/sql/llx_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : '');
|
||||||
|
|
||||||
$contentsql = file_get_contents(dol_os_encode($pathoffiletoeditsrc), 'r');
|
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
$texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n";
|
$texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n";
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ if ($dirins && $action == 'initmodule' && $modulename)
|
|||||||
dol_delete_file($destdir.'/img/object_myobject.png');
|
dol_delete_file($destdir.'/img/object_myobject.png');
|
||||||
dol_delete_file($destdir.'/class/myobject.class.php');
|
dol_delete_file($destdir.'/class/myobject.class.php');
|
||||||
dol_delete_file($destdir.'/class/api_myobject.class.php');
|
dol_delete_file($destdir.'/class/api_myobject.class.php');
|
||||||
dol_delete_file($destdir.'/class/MyObject.txt');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit PHP files
|
// Edit PHP files
|
||||||
@@ -215,8 +214,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
|
|||||||
'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php',
|
'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php',
|
||||||
'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png',
|
'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png',
|
||||||
'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php',
|
'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php',
|
||||||
'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php',
|
'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php'
|
||||||
'class/MyObject.txt'=>'class/'.$objectname.'.txt'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($filetogenerate as $srcfile => $destfile)
|
foreach($filetogenerate as $srcfile => $destfile)
|
||||||
@@ -418,8 +416,7 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname)
|
|||||||
'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php',
|
'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php',
|
||||||
'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png',
|
'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png',
|
||||||
'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php',
|
'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php',
|
||||||
'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php',
|
'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php'
|
||||||
'class/MyObject.txt'=>'class/'.$objectname.'.txt'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$resultko = 0;
|
$resultko = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user