26require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
32require_once DOL_DOCUMENT_ROOT.
"/knowledgemanagement/lib/knowledgemanagement.lib.php";
35$langs->loadLangs(array(
"admin",
"knowledgemanagement"));
38$action =
GETPOST(
'action',
'aZ09');
39$backtopage =
GETPOST(
'backtopage',
'alpha');
40$value =
GETPOST(
'value',
'alpha');
41$modulepart =
GETPOST(
'modulepart',
'aZ09');
43$label =
GETPOST(
'label',
'alpha');
44$scandir =
GETPOST(
'scan_dir',
'alpha');
45$type =
'knowledgemanagement';
47$arrayofparameters = array(
48 'KNOWLEDGEMANAGEMENT_MYPARAM1'=>array(
'type'=>
'string',
'css'=>
'minwidth500' ,
'enabled'=>0),
69include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
71if ($action ==
'updateMask') {
72 $maskconst =
GETPOST(
'maskconst',
'aZ09');
73 $maskorder =
GETPOST(
'maskorder',
'alpha');
75 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
76 $res =
dolibarr_set_const($db, $maskconst, $maskorder,
'chaine', 0,
'', $conf->entity);
87} elseif ($action ==
'specimen') {
88 $modele =
GETPOST(
'module',
'alpha');
89 $tmpobjectkey =
GETPOST(
'object');
91 $tmpobject =
new $tmpobjectkey($db);
92 $tmpobject->initAsSpecimen();
98 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
99 foreach ($dirmodels as $reldir) {
100 $file =
dol_buildpath($reldir.
"core/modules/knowledgemanagement/doc/pdf_".$modele.
"_".strtolower($tmpobjectkey).
".modules.php", 0);
101 if (file_exists($file)) {
103 $classname =
"pdf_".$modele;
111 $module =
new $classname($db);
113 if ($module->write_file($tmpobject, $langs) > 0) {
114 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
122 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
124} elseif ($action ==
'setmod') {
126 $tmpobjectkey =
GETPOST(
'object');
127 if (!empty($tmpobjectkey)) {
128 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
"_ADDON";
131} elseif ($action ==
'set') {
134} elseif ($action ==
'del') {
137 $tmpobjectkey =
GETPOST(
'object');
138 if (!empty($tmpobjectkey)) {
139 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
145} elseif ($action ==
'setdoc') {
147 $tmpobjectkey =
GETPOST(
'object');
148 if (!empty($tmpobjectkey)) {
149 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
153 $conf->global->$constforval = $value;
162} elseif ($action ==
'unsetdoc') {
163 $tmpobjectkey =
GETPOST(
'object');
164 if (!empty($tmpobjectkey)) {
165 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
176$form =
new Form($db);
178$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
180$page_name =
"KnowledgeManagementSetup";
184$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
190print
dol_get_fiche_head($head,
'setup', $langs->trans(
'ModuleKnowledgeManagementName'), -1,
"knowledgemanagement");
193echo
'<span class="opacitymedium">'.$langs->trans(
"KnowledgeManagementSetupPage").
'</span><br><br>';
196if ($action ==
'edit') {
197 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
198 print
'<input type="hidden" name="token" value="'.newToken().
'">';
199 print
'<input type="hidden" name="action" value="update">';
201 print
'<table class="noborder centpercent">';
202 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
204 foreach ($arrayofparameters as $constname => $val) {
205 if ($val[
'enabled']==1) {
207 print
'<tr class="oddeven"><td>';
208 $tooltiphelp = (($langs->trans($constname .
'Tooltip') != $constname .
'Tooltip') ? $langs->trans($constname .
'Tooltip') :
'');
209 print
'<span id="helplink'.$constname.
'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1,
'info',
'', 0, 3,
'tootips'.$constname).
'</span>';
212 if ($val[
'type'] ==
'textarea') {
213 print
'<textarea class="flat" name="' . $constname .
'" id="' . $constname .
'" cols="50" rows="5" wrap="soft">' .
"\n";
215 print
"</textarea>\n";
216 } elseif ($val[
'type'] ==
'html') {
217 require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
218 $doleditor =
new DolEditor($constname,
getDolGlobalString($constname),
'', 160,
'dolibarr_notes',
'',
false,
false, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
219 $doleditor->Create();
220 } elseif ($val[
'type'] ==
'yesno') {
222 } elseif (preg_match(
'/emailtemplate:/', $val[
'type'])) {
223 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
226 $tmp = explode(
':', $val[
'type']);
227 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, 1);
229 $arrayofmessagename = array();
230 if (is_array($formmail->lines_model)) {
231 foreach ($formmail->lines_model as $modelmail) {
234 if (!empty($arrayofmessagename[$modelmail->label])) {
235 $moreonlabel =
' <span class="opacitymedium">(' . $langs->trans(
"SeveralLangugeVariatFound") .
')</span>';
238 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)) . $moreonlabel;
241 print $form->selectarray($constname, $arrayofmessagename,
getDolGlobalString($constname),
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
242 } elseif (preg_match(
'/category:/', $val[
'type'])) {
243 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
244 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
247 $tmp = explode(
':', $val[
'type']);
248 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
249 print $formother->select_categories($tmp[1],
getDolGlobalString($constname), $constname, 0, $langs->trans(
'CustomersProspectsCategoriesShort'));
250 } elseif (preg_match(
'/thirdparty_type/', $val[
'type'])) {
251 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
253 print $formcompany->selectProspectCustomerType(
getDolGlobalString($constname), $constname);
255 print
'<input name="'.$constname.
'" class="flat '.(empty($val[
'css']) ?
'minwidth200' : $val[
'css']).
'" value="'.
getDolGlobalString($constname).
'">';
262 print $form->buttonsSaveCancel(
"Save",
'');
267 if (!empty($arrayofparameters)) {
268 print
'<table class="noborder centpercent">';
269 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
271 foreach ($arrayofparameters as $constname => $val) {
272 if ($val[
'enabled']==1) {
274 print
'<tr class="oddeven"><td>';
275 $tooltiphelp = (($langs->trans($constname .
'Tooltip') != $constname .
'Tooltip') ? $langs->trans($constname .
'Tooltip') :
'');
276 print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
279 if ($val[
'type'] ==
'textarea') {
281 } elseif ($val[
'type']==
'html') {
283 } elseif ($val[
'type'] ==
'yesno') {
284 print ajax_constantonoff($constname);
285 } elseif (preg_match(
'/emailtemplate:/', $val[
'type'])) {
286 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
289 $tmp = explode(
':', $val[
'type']);
291 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs,
getDolGlobalString($constname));
295 print $langs->trans($template->label);
296 } elseif (preg_match(
'/category:/', $val[
'type'])) {
302 $ways = $c->print_all_ways(
' >> ',
'none', 0, 1);
304 foreach ($ways as $way) {
305 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' . $way .
'</li>';
307 print
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
308 } elseif (preg_match(
'/thirdparty_type/', $val[
'type'])) {
310 print $langs->trans(
"Prospect");
312 print $langs->trans(
"ProspectCustomer");
314 print $langs->trans(
"Customer");
316 print $langs->trans(
"NorProspectNorCustomer");
327 print
'<div class="tabsAction">';
328 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
336$moduledir =
'knowledgemanagement';
337$myTmpObjects = array();
338$myTmpObjects[
'MyObject'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
341foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
342 if ($myTmpObjectKey ==
'MyObject') {
345 if ($myTmpObjectArray[
'includerefgeneration']) {
351 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
353 print
'<table class="noborder centpercent">';
354 print
'<tr class="liste_titre">';
355 print
'<td>'.$langs->trans(
"Name").
'</td>';
356 print
'<td>'.$langs->trans(
"Description").
'</td>';
357 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
358 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
359 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
364 foreach ($dirmodels as $reldir) {
368 $handle = opendir($dir);
369 if (is_resource($handle)) {
370 while (($file = readdir($handle)) !==
false) {
371 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
372 $file = substr($file, 0,
dol_strlen($file) - 4);
374 require_once $dir.
'/'.$file.
'.php';
376 $module =
new $file($db);
379 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
382 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
386 if ($module->isEnabled()) {
387 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
389 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
390 print $module->info($langs);
394 print
'<td class="nowrap">';
395 $tmp = $module->getExample();
396 if (preg_match(
'/^Error/', $tmp)) {
397 $langs->load(
"errors");
398 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
399 } elseif ($tmp ==
'NotConfigured') {
400 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
406 print
'<td class="center">';
407 $constforvar =
'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).
'_ADDON';
409 print
img_picto($langs->trans(
"Activated"),
'switch_on');
411 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.urlencode($file).
'">';
412 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
417 $mytmpinstance =
new $myTmpObjectKey($db);
418 $mytmpinstance->initAsSpecimen();
422 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
424 $nextval = $module->getNextValue($mytmpinstance);
425 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
426 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
428 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
429 $nextval = $langs->trans($nextval);
431 $htmltooltip .= $nextval.
'<br>';
433 $htmltooltip .= $langs->trans($module->error).
'<br>';
437 print
'<td class="center">';
438 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
449 print
"</table><br>\n";
452 if ($myTmpObjectArray[
'includedocgeneration']) {
457 $type = strtolower($myTmpObjectKey);
459 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
464 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
465 $sql .=
" WHERE type = '".$db->escape($type).
"'";
466 $sql .=
" AND entity = ".$conf->entity;
467 $resql = $db->query($sql);
470 $num_rows = $db->num_rows($resql);
471 while ($i < $num_rows) {
472 $array = $db->fetch_array($resql);
473 array_push($def, $array[0]);
480 print
"<table class=\"noborder\" width=\"100%\">\n";
481 print
"<tr class=\"liste_titre\">\n";
482 print
'<td>'.$langs->trans(
"Name").
'</td>';
483 print
'<td>'.$langs->trans(
"Description").
'</td>';
484 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
485 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
486 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
487 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
492 foreach ($dirmodels as $reldir) {
493 foreach (array(
'',
'/doc') as $valdir) {
494 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
498 $handle = opendir($dir);
499 if (is_resource($handle)) {
500 while (($file = readdir($handle)) !==
false) {
506 foreach ($filelist as $file) {
507 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
508 if (file_exists($dir.
'/'.$file)) {
509 $name = substr($file, 4,
dol_strlen($file) - 16);
510 $classname = substr($file, 0,
dol_strlen($file) - 12);
512 require_once $dir.
'/'.$file;
513 $module =
new $classname($db);
515 $modulequalified = 1;
516 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
517 $modulequalified = 0;
519 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
520 $modulequalified = 0;
523 if ($modulequalified) {
524 print
'<tr class="oddeven"><td width="100">';
525 print(empty($module->name) ? $name : $module->
name);
527 if (method_exists($module,
'info')) {
528 print $module->info($langs);
530 print $module->description;
535 if (in_array($name, $def)) {
536 print
'<td class="center">'.
"\n";
537 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'">';
538 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
542 print
'<td class="center">'.
"\n";
543 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
548 print
'<td class="center">';
549 $constforvar =
'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).
'_ADDON';
553 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type='.urlencode($type).
'" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
555 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.$name.
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
560 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
561 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
562 if ($module->type ==
'pdf') {
563 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
565 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
567 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
568 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
569 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
571 print
'<td class="center">';
572 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
576 print
'<td class="center">';
577 if ($module->type ==
'pdf') {
578 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
580 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
598if (empty($setupnotempty)) {
599 print
'<br>'.$langs->trans(
"NothingToSetup");
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
delDocumentModel($name, $type)
Delete document model used by doc generator.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage categories.
Class to manage a WYSIWYG editor.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
knowledgemanagementAdminPrepareHead()
Prepare admin pages header.
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.