29 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
48 $this->numero = 500000;
51 $this->rights_class =
'mymodule';
55 $this->family =
"other";
58 $this->module_position =
'90';
63 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
68 $this->descriptionlong =
"MyModuleDescription";
71 $this->editor_name =
'Editor name';
72 $this->editor_url =
'https://www.example.com';
75 $this->version =
'1.0';
80 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
86 $this->picto =
'generic';
89 $this->module_parts = array(
125 'moduleforexternal' => 0,
130 $this->dirs = array(
"/mymodule/temp");
133 $this->config_page_url = array(
"setup.php@mymodule");
137 $this->hidden =
false;
139 $this->depends = array();
140 $this->requiredby = array();
141 $this->conflictwith = array();
144 $this->langfiles = array(
"mymodule@mymodule");
147 $this->phpmin = array(7, 0);
148 $this->need_dolibarr_version = array(11, -3);
151 $this->warnings_activation = array();
152 $this->warnings_activation_ext = array();
161 $this->
const = array();
169 if (!isset($conf->mymodule) || !isset($conf->mymodule->enabled)) {
170 $conf->mymodule =
new stdClass();
171 $conf->mymodule->enabled = 0;
175 $this->tabs = array();
203 $this->dictionaries = array();
232 $this->boxes = array(
243 $this->cronjobs = array(
265 $this->rights = array();
269 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
270 $this->rights[$r][1] =
'Read objects of MyModule';
271 $this->rights[$r][4] =
'myobject';
272 $this->rights[$r][5] =
'read';
274 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
275 $this->rights[$r][1] =
'Create/Update objects of MyModule';
276 $this->rights[$r][4] =
'myobject';
277 $this->rights[$r][5] =
'write';
279 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
280 $this->rights[$r][1] =
'Delete objects of MyModule';
281 $this->rights[$r][4] =
'myobject';
282 $this->rights[$r][5] =
'delete';
287 $this->menu = array();
291 $this->menu[$r++] = array(
294 'titre'=>
'ModuleMyModuleName',
295 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth valignmiddle"'),
296 'mainmenu'=>
'mymodule',
298 'url'=>
'/mymodule/mymoduleindex.php',
299 'langs'=>
'mymodule@mymodule',
300 'position'=>1000 + $r,
301 'enabled'=>
'isModEnabled("mymodule")',
427 public function init($options =
'')
429 global $conf, $langs;
447 $this->
remove($options);
453 $myTmpObjects = array();
454 $myTmpObjects[
'MyObject'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
456 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
457 if ($myTmpObjectKey ==
'MyObject') {
460 if ($myTmpObjectArray[
'includerefgeneration']) {
461 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/'.$moduledir.
'/template_myobjects.odt';
462 $dirodt = DOL_DATA_ROOT.
'/doctemplates/'.$moduledir;
463 $dest = $dirodt.
'/template_myobjects.odt';
465 if (file_exists($src) && !file_exists($dest)) {
466 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
468 $result =
dol_copy($src, $dest, 0, 0);
470 $langs->load(
"errors");
471 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
476 $sql = array_merge($sql, array(
477 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey).
"' AND type = '".$this->
db->escape(strtolower($myTmpObjectKey)).
"' AND entity = ".((
int) $conf->entity),
478 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey).
"', '".$this->
db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")",
479 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey).
"_odt' AND type = '".$this->
db->escape(strtolower($myTmpObjectKey)).
"' AND entity = ".((
int) $conf->entity),
480 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey).
"_odt', '".$this->
db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")"
485 return $this->
_init($sql, $options);
496 public function remove($options =
'')
499 return $this->
_remove($sql, $options);
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Description and activation class for module MyModule.
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.