30include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
49 $this->numero = 57000;
52 $this->rights_class =
'knowledgemanagement';
56 $this->family =
"crm";
59 $this->module_position =
'61';
64 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
69 $this->descriptionlong =
"Manage a Knowledge Management (KM) or Help-Desk base";
72 $this->version =
'dolibarr';
77 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
83 $this->picto =
'knowledgemanagement';
86 $this->module_parts = array(
122 'moduleforexternal' => 0,
127 $this->dirs = array(
"/knowledgemanagement/temp");
130 $this->config_page_url = array(
"knowledgemanagement.php");
134 $this->hidden =
false;
136 $this->depends = array();
137 $this->requiredby = array();
138 $this->conflictwith = array();
141 $this->langfiles = array(
"knowledgemanagement");
144 $this->phpmin = array(7, 0);
145 $this->need_dolibarr_version = array(11, -3);
148 $this->warnings_activation = array();
149 $this->warnings_activation_ext = array();
157 $this->
const = array();
165 if (!isset($conf->knowledgemanagement) || !isset($conf->knowledgemanagement->enabled)) {
166 $conf->knowledgemanagement =
new stdClass();
167 $conf->knowledgemanagement->enabled = 0;
171 $this->tabs = array();
199 $this->dictionaries = array();
203 $this->boxes = array(
205 'file' =>
'box_last_knowledgerecord.php',
206 'enabledbydefaulton' =>
'ticketindex',
209 'file' =>
'box_last_modified_knowledgerecord.php',
210 'enabledbydefaulton' =>
'ticketindex',
216 $this->cronjobs = array(
238 $this->rights = array();
242 $this->rights[$r][0] = $this->numero + $r + 1;
243 $this->rights[$r][1] =
'Read articles';
244 $this->rights[$r][4] =
'knowledgerecord';
245 $this->rights[$r][5] =
'read';
247 $this->rights[$r][0] = $this->numero + $r + 1;
248 $this->rights[$r][1] =
'Create/Update articles';
249 $this->rights[$r][4] =
'knowledgerecord';
250 $this->rights[$r][5] =
'write';
252 $this->rights[$r][0] = $this->numero + $r + 1;
253 $this->rights[$r][1] =
'Validate articles';
254 $this->rights[$r][4] =
'knowledgerecord_advance';
255 $this->rights[$r][5] =
'validate';
257 $this->rights[$r][0] = $this->numero + $r + 1;
258 $this->rights[$r][1] =
'Delete articles';
259 $this->rights[$r][4] =
'knowledgerecord';
260 $this->rights[$r][5] =
'delete';
265 $this->menu = array();
288 $this->menu[$r++] = array(
290 'fk_menu' =>
'fk_mainmenu=ticket',
293 'titre' =>
'MenuKnowledgeRecord',
294 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth em092"'),
295 'mainmenu' =>
'ticket',
296 'leftmenu' =>
'knowledgemanagement_knowledgerecord',
297 'url' =>
'/knowledgemanagement/knowledgerecord_list.php',
299 'langs' =>
'knowledgemanagement',
302 'enabled' =>
'isModEnabled("knowledgemanagement")',
304 'perms' =>
'$user->hasRight("knowledgemanagement", "knowledgerecord", "read")',
309 $this->menu[$r++] = array(
311 'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=knowledgemanagement_knowledgerecord',
314 'titre' =>
'ListKnowledgeRecord',
315 'mainmenu' =>
'ticket',
316 'leftmenu' =>
'knowledgemanagement_list',
317 'url' =>
'/knowledgemanagement/knowledgerecord_list.php',
319 'langs' =>
'knowledgemanagement',
322 'enabled' =>
'isModEnabled("knowledgemanagement")',
324 'perms' =>
'$user->hasRight("knowledgemanagement", "knowledgerecord", "read")',
329 $this->menu[$r++] = array(
331 'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=knowledgemanagement_knowledgerecord',
334 'titre' =>
'NewKnowledgeRecord',
335 'mainmenu' =>
'ticket',
336 'leftmenu' =>
'knowledgemanagement_new',
337 'url' =>
'/knowledgemanagement/knowledgerecord_card.php?action=create',
339 'langs' =>
'knowledgemanagement',
342 'enabled' =>
'isModEnabled("knowledgemanagement")',
344 'perms' =>
'$user->hasRight("knowledgemanagement", "knowledgerecord", "write")',
349 $this->menu[$r++] = array(
350 'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=knowledgemanagement_knowledgerecord',
352 'titre' =>
'Categories',
353 'mainmenu' =>
'ticket',
354 'url' =>
'/categories/categorie_list.php?type=13',
355 'langs' =>
'knowledgemanagement',
357 'enabled' =>
'isModEnabled("knowledgemanagement") && isModEnabled("category") && getDolGlobalString("CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP")',
358 'perms' =>
'$user->hasRight("knowledgemanagement", "knowledgerecord", "read")',
425 public function init($options =
'')
427 global $conf, $langs;
429 $result = $this->
_load_tables(
'/install/mysql/',
'knowledgemanagement');
444 $this->
remove($options);
449 $moduledir =
'knowledgemanagement';
450 $myTmpObjects = array();
451 $myTmpObjects[
'KnowledgeRecord'] = array(
'includerefgeneration' => 0,
'includedocgeneration' => 0);
453 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
454 if ($myTmpObjectArray[
'includerefgeneration']) {
455 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/knowledgemanagement/template_knowledgerecords.odt';
456 $dirodt = DOL_DATA_ROOT.
'/doctemplates/knowledgemanagement';
457 $dest = $dirodt.
'/template_knowledgerecords.odt';
459 if (file_exists($src) && !file_exists($dest)) {
460 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
462 $result =
dol_copy($src, $dest,
'0', 0);
464 $langs->load(
"errors");
465 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
470 $sql = array_merge($sql, array(
471 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey).
"' AND type = '".strtolower($myTmpObjectKey).
"' AND entity = ".((
int) $conf->entity),
472 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey).
"','".strtolower($myTmpObjectKey).
"',".((
int) $conf->entity).
")",
473 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey).
"_odt' AND type = '".strtolower($myTmpObjectKey).
"' AND entity = ".((
int) $conf->entity),
474 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey).
"_odt', '".strtolower($myTmpObjectKey).
"', ".((
int) $conf->entity).
")"
479 return $this->
_init($sql, $options);
490 public function remove($options =
'')
493 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 KnowledgeManagement.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
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, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.