29include_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();
141 $this->requiredby = array();
143 $this->conflictwith = array();
146 $this->langfiles = array(
"mymodule@mymodule");
149 $this->phpmin = array(7, 0);
150 $this->need_dolibarr_version = array(11, -3);
151 $this->need_javascript_ajax = 0;
154 $this->warnings_activation = array();
155 $this->warnings_activation_ext = array();
164 $this->
const = array();
172 if (!isModEnabled(
"mymodule")) {
174 $conf->mymodule->enabled = 0;
178 $this->tabs = array();
232 $this->dictionaries = array();
238 $this->boxes = array(
251 $this->cronjobs = array(
274 $this->rights = array();
299 $this->menu = array();
303 $this->menu[$r++] = array(
306 'titre'=>
'ModuleMyModuleName',
307 'prefix' =>
img_picto(
'', $this->picto,
'class="pictofixedwidth valignmiddle"'),
308 'mainmenu'=>
'mymodule',
310 'url'=>
'/mymodule/mymoduleindex.php',
311 'langs'=>
'mymodule@mymodule',
312 'position'=>1000 + $r,
313 'enabled'=>
'isModEnabled("mymodule")',
442 public function init($options =
'')
444 global $conf, $langs;
462 $this->
remove($options);
468 $myTmpObjects = array();
469 $myTmpObjects[
'MyObject'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
471 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
472 if ($myTmpObjectKey ==
'MyObject') {
475 if ($myTmpObjectArray[
'includerefgeneration']) {
476 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/'.$moduledir.
'/template_myobjects.odt';
477 $dirodt = DOL_DATA_ROOT.
'/doctemplates/'.$moduledir;
478 $dest = $dirodt.
'/template_myobjects.odt';
480 if (file_exists($src) && !file_exists($dest)) {
481 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
483 $result =
dol_copy($src, $dest, 0, 0);
485 $langs->load(
"errors");
486 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
491 $sql = array_merge($sql, array(
492 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey).
"' AND type = '".$this->db->escape(strtolower($myTmpObjectKey)).
"' AND entity = ".((
int) $conf->entity),
493 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey).
"', '".$this->db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")",
494 "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),
495 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey).
"_odt', '".$this->db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")"
500 return $this->
_init($sql, $options);
511 public function remove($options =
'')
514 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 $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after 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, $testvirus=0, $indexdatabase=0)
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.