29include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
50 $this->numero = 500000;
53 $this->rights_class =
'mymodule';
57 $this->family =
"other";
60 $this->module_position =
'90';
65 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
71 $this->descriptionlong =
"MyModuleDescription";
74 $this->editor_name =
'Editor name';
75 $this->editor_url =
'https://www.example.com';
76 $this->editor_squarred_logo =
'';
79 $this->version =
'1.0';
84 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
90 $this->picto =
'generic';
93 $this->module_parts = array(
131 'moduleforexternal' => 0,
133 'websitetemplates' => 0,
140 $this->dirs = array(
"/mymodule/temp");
143 $this->config_page_url = array(
"setup.php@mymodule");
149 $this->depends = array();
151 $this->requiredby = array();
153 $this->conflictwith = array();
156 $this->langfiles = array(
"mymodule@mymodule");
159 $this->phpmin = array(7, 1);
160 $this->need_dolibarr_version = array(19, -3);
161 $this->need_javascript_ajax = 0;
164 $this->warnings_activation = array();
165 $this->warnings_activation_ext = array();
174 $this->
const = array();
182 if (!isModEnabled(
"mymodule")) {
184 $conf->mymodule->enabled = 0;
189 $this->tabs = array();
249 $this->dictionaries = array();
255 $this->boxes = array(
268 $this->cronjobs = array(
291 $this->rights = array();
317 $this->menu = array();
321 $this->menu[$r++] = array(
324 'titre' =>
'ModuleMyModuleName',
325 'prefix' =>
img_picto(
'', $this->picto,
'class="pictofixedwidth valignmiddle"'),
326 'mainmenu' =>
'mymodule',
328 'url' =>
'/mymodule/mymoduleindex.php',
329 'langs' =>
'mymodule@mymodule',
330 'position' => 1000 + $r,
331 'enabled' =>
'isModEnabled("mymodule")',
466 public function init($options =
'')
468 global
$conf, $langs;
488 $this->
remove($options);
494 $myTmpObjects = array();
495 $myTmpObjects[
'MyObject'] = array(
'includerefgeneration' => 0,
'includedocgeneration' => 0);
497 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
498 if ($myTmpObjectArray[
'includerefgeneration']) {
499 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/'.$moduledir.
'/template_myobjects.odt';
500 $dirodt = DOL_DATA_ROOT.
'/doctemplates/'.$moduledir;
501 $dest = $dirodt.
'/template_myobjects.odt';
503 if (file_exists($src) && !file_exists($dest)) {
504 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
506 $result =
dol_copy($src, $dest,
'0', 0);
508 $langs->load(
"errors");
509 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
514 $sql = array_merge($sql, array(
515 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey).
"' AND type = '".$this->db->escape(strtolower($myTmpObjectKey)).
"' AND entity = ".((
int)
$conf->entity),
516 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey).
"', '".$this->db->escape(strtolower($myTmpObjectKey)).
"', ".((
int)
$conf->entity).
")",
517 "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),
518 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey).
"_odt', '".$this->db->escape(strtolower($myTmpObjectKey)).
"', ".((
int)
$conf->entity).
")"
523 return $this->
_init($sql, $options);
534 public function remove($options =
'')
537 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=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$conf db name
Only used if Module[ID]Name translation string is not found.