Debug module builder for generation of APIs

This commit is contained in:
Laurent Destailleur
2019-05-02 12:03:14 +02:00
parent 3a8d645fb9
commit 4756499a81
7 changed files with 219 additions and 101 deletions

View File

@@ -170,6 +170,7 @@ class modMyModule extends DolibarrModules
// 'stock' to add a tab in stock view
// 'thirdparty' to add a tab in third party view
// 'user' to add a tab in user view
// Dictionaries
$this->dictionaries=array();
/* Example:
@@ -195,6 +196,7 @@ class modMyModule extends DolibarrModules
'tabcond'=>array($conf->mymodule->enabled,$conf->mymodule->enabled,$conf->mymodule->enabled)
);
*/
// Boxes/Widgets
// Add here list of php file(s) stored in mymodule/core/boxes that contains class to show a widget.
$this->boxes = array(
@@ -206,6 +208,7 @@ class modMyModule extends DolibarrModules
//1=>array('file'=>'mymodulewidget2.php@mymodule','note'=>'Widget provided by MyModule'),
//2=>array('file'=>'mymodulewidget3.php@mymodule','note'=>'Widget provided by MyModule')
);
// Cronjobs (List of cron jobs entries to add when module is enabled)
// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
$this->cronjobs = array(
@@ -228,26 +231,28 @@ class modMyModule extends DolibarrModules
// 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50)
// );
// Permissions
$this->rights = array(); // Permission array used by this module
$r=0;
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
$this->rights[$r][1] = 'Read myobject of MyModule'; // Permission label
$this->rights[$r][1] = 'Read objects of MyModule'; // Permission label
$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
$r++;
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
$this->rights[$r][1] = 'Create/Update myobject of MyModule'; // Permission label
$this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label
$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
$r++;
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
$this->rights[$r][1] = 'Delete myobject of MyModule'; // Permission label
$this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label
$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
// Main menu entries
$this->menu = array(); // List of menus to add
$r=0;
@@ -298,6 +303,7 @@ class modMyModule extends DolibarrModules
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
);
END MODULEBUILDER LEFTMENU MYOBJECT */
// Exports
$r=1;
/* BEGIN MODULEBUILDER EXPORT MYOBJECT */
@@ -317,6 +323,26 @@ class modMyModule extends DolibarrModules
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
$r++; */
/* END MODULEBUILDER EXPORT MYOBJECT */
// Imports
$r=1;
/* BEGIN MODULEBUILDER IMPORT MYOBJECT */
/*
$langs->load("mymodule@mymodule");
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='myobject@mymodule';
$keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
$this->export_sql_end[$r] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
$r++; */
/* END MODULEBUILDER IMPORT MYOBJECT */
}
/**
* Function called when module is enabled.