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();
95 $file =
''; $classname =
''; $filefound = 0;
96 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
97 foreach ($dirmodels as $reldir) {
98 $file =
dol_buildpath($reldir.
"core/modules/knowledgemanagement/doc/pdf_".$modele.
"_".strtolower($tmpobjectkey).
".modules.php", 0);
99 if (file_exists($file)) {
101 $classname =
"pdf_".$modele;
109 $module =
new $classname($db);
111 if ($module->write_file($tmpobject, $langs) > 0) {
112 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
120 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
122} elseif ($action ==
'setmod') {
124 $tmpobjectkey =
GETPOST(
'object');
125 if (!empty($tmpobjectkey)) {
126 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
"_ADDON";
129} elseif ($action ==
'set') {
132} elseif ($action ==
'del') {
135 $tmpobjectkey =
GETPOST(
'object');
136 if (!empty($tmpobjectkey)) {
137 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
138 if ($conf->global->$constforval ==
"$value") {
143} elseif ($action ==
'setdoc') {
145 $tmpobjectkey =
GETPOST(
'object');
146 if (!empty($tmpobjectkey)) {
147 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
151 $conf->global->$constforval = $value;
160} elseif ($action ==
'unsetdoc') {
161 $tmpobjectkey =
GETPOST(
'object');
162 if (!empty($tmpobjectkey)) {
163 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
174$form =
new Form($db);
176$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
178$page_name =
"KnowledgeManagementSetup";
182$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
188print
dol_get_fiche_head($head,
'setup', $langs->trans(
'ModuleKnowledgeManagementName'), -1,
"knowledgemanagement");
191echo
'<span class="opacitymedium">'.$langs->trans(
"KnowledgeManagementSetupPage").
'</span><br><br>';
194if ($action ==
'edit') {
195 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
196 print
'<input type="hidden" name="token" value="'.newToken().
'">';
197 print
'<input type="hidden" name="action" value="update">';
199 print
'<table class="noborder centpercent">';
200 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
202 foreach ($arrayofparameters as $constname => $val) {
203 if ($val[
'enabled']==1) {
205 print
'<tr class="oddeven"><td>';
206 $tooltiphelp = (($langs->trans($constname .
'Tooltip') != $constname .
'Tooltip') ? $langs->trans($constname .
'Tooltip') :
'');
207 print
'<span id="helplink'.$constname.
'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1,
'info',
'', 0, 3,
'tootips'.$constname).
'</span>';
210 if ($val[
'type'] ==
'textarea') {
211 print
'<textarea class="flat" name="' . $constname .
'" id="' . $constname .
'" cols="50" rows="5" wrap="soft">' .
"\n";
213 print
"</textarea>\n";
214 } elseif ($val[
'type'] ==
'html') {
215 require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
216 $doleditor =
new DolEditor($constname,
getDolGlobalString($constname),
'', 160,
'dolibarr_notes',
'',
false,
false, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
217 $doleditor->Create();
218 } elseif ($val[
'type'] ==
'yesno') {
220 } elseif (preg_match(
'/emailtemplate:/', $val[
'type'])) {
221 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
224 $tmp = explode(
':', $val[
'type']);
225 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, 1);
227 $arrayofmessagename = array();
228 if (is_array($formmail->lines_model)) {
229 foreach ($formmail->lines_model as $modelmail) {
232 if (!empty($arrayofmessagename[$modelmail->label])) {
233 $moreonlabel =
' <span class="opacitymedium">(' . $langs->trans(
"SeveralLangugeVariatFound") .
')</span>';
236 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)) . $moreonlabel;
239 print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname},
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
240 } elseif (preg_match(
'/category:/', $val[
'type'])) {
241 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
242 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
245 $tmp = explode(
':', $val[
'type']);
246 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
247 print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans(
'CustomersProspectsCategoriesShort'));
248 } elseif (preg_match(
'/thirdparty_type/', $val[
'type'])) {
249 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
251 print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname);
253 print
'<input name="'.$constname.
'" class="flat '.(empty($val[
'css']) ?
'minwidth200' : $val[
'css']).
'" value="'.$conf->global->{$constname}.
'">';
260 print $form->buttonsSaveCancel(
"Save",
'');
265 if (!empty($arrayofparameters)) {
266 print
'<table class="noborder centpercent">';
267 print
'<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
269 foreach ($arrayofparameters as $constname => $val) {
270 if ($val[
'enabled']==1) {
272 print
'<tr class="oddeven"><td>';
273 $tooltiphelp = (($langs->trans($constname .
'Tooltip') != $constname .
'Tooltip') ? $langs->trans($constname .
'Tooltip') :
'');
274 print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
277 if ($val[
'type'] ==
'textarea') {
279 } elseif ($val[
'type']==
'html') {
281 } elseif ($val[
'type'] ==
'yesno') {
282 print ajax_constantonoff($constname);
283 } elseif (preg_match(
'/emailtemplate:/', $val[
'type'])) {
284 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
287 $tmp = explode(
':', $val[
'type']);
289 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs,
getDolGlobalString($constname));
293 print $langs->trans($template->label);
294 } elseif (preg_match(
'/category:/', $val[
'type'])) {
296 $result = $c->fetch($conf->global->{$constname});
300 $ways = $c->print_all_ways(
' >> ',
'none', 0, 1);
302 foreach ($ways as $way) {
303 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' . $way .
'</li>';
305 print
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
306 } elseif (preg_match(
'/thirdparty_type/', $val[
'type'])) {
308 print $langs->trans(
"Prospect");
310 print $langs->trans(
"ProspectCustomer");
312 print $langs->trans(
"Customer");
314 print $langs->trans(
"NorProspectNorCustomer");
325 print
'<div class="tabsAction">';
326 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
334$moduledir =
'knowledgemanagement';
335$myTmpObjects = array();
336$myTmpObjects[
'MyObject'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
339foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
340 if ($myTmpObjectKey ==
'MyObject') {
343 if ($myTmpObjectArray[
'includerefgeneration']) {
349 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
351 print
'<table class="noborder centpercent">';
352 print
'<tr class="liste_titre">';
353 print
'<td>'.$langs->trans(
"Name").
'</td>';
354 print
'<td>'.$langs->trans(
"Description").
'</td>';
355 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
356 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
357 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
362 foreach ($dirmodels as $reldir) {
366 $handle = opendir($dir);
367 if (is_resource($handle)) {
368 while (($file = readdir($handle)) !==
false) {
369 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
370 $file = substr($file, 0,
dol_strlen($file) - 4);
372 require_once $dir.
'/'.$file.
'.php';
374 $module =
new $file($db);
377 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
380 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
384 if ($module->isEnabled()) {
385 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
387 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
388 print $module->info();
392 print
'<td class="nowrap">';
393 $tmp = $module->getExample();
394 if (preg_match(
'/^Error/', $tmp)) {
395 $langs->load(
"errors");
396 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
397 } elseif ($tmp ==
'NotConfigured') {
398 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
404 print
'<td class="center">';
405 $constforvar =
'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).
'_ADDON';
407 print
img_picto($langs->trans(
"Activated"),
'switch_on');
409 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.urlencode($file).
'">';
410 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
415 $mytmpinstance =
new $myTmpObjectKey($db);
416 $mytmpinstance->initAsSpecimen();
420 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
422 $nextval = $module->getNextValue($mytmpinstance);
423 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
424 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
426 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
427 $nextval = $langs->trans($nextval);
429 $htmltooltip .= $nextval.
'<br>';
431 $htmltooltip .= $langs->trans($module->error).
'<br>';
435 print
'<td class="center">';
436 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
447 print
"</table><br>\n";
450 if ($myTmpObjectArray[
'includedocgeneration']) {
455 $type = strtolower($myTmpObjectKey);
457 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
462 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
463 $sql .=
" WHERE type = '".$db->escape($type).
"'";
464 $sql .=
" AND entity = ".$conf->entity;
465 $resql = $db->query($sql);
468 $num_rows = $db->num_rows($resql);
469 while ($i < $num_rows) {
470 $array = $db->fetch_array($resql);
471 array_push($def, $array[0]);
478 print
"<table class=\"noborder\" width=\"100%\">\n";
479 print
"<tr class=\"liste_titre\">\n";
480 print
'<td>'.$langs->trans(
"Name").
'</td>';
481 print
'<td>'.$langs->trans(
"Description").
'</td>';
482 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
483 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
484 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
485 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
490 foreach ($dirmodels as $reldir) {
491 foreach (array(
'',
'/doc') as $valdir) {
492 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
496 $handle = opendir($dir);
497 if (is_resource($handle)) {
498 while (($file = readdir($handle)) !==
false) {
504 foreach ($filelist as $file) {
505 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
506 if (file_exists($dir.
'/'.$file)) {
507 $name = substr($file, 4,
dol_strlen($file) - 16);
508 $classname = substr($file, 0,
dol_strlen($file) - 12);
510 require_once $dir.
'/'.$file;
511 $module =
new $classname($db);
513 $modulequalified = 1;
514 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
515 $modulequalified = 0;
517 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
518 $modulequalified = 0;
521 if ($modulequalified) {
522 print
'<tr class="oddeven"><td width="100">';
523 print (empty($module->name) ? $name : $module->
name);
525 if (method_exists($module,
'info')) {
526 print $module->info($langs);
528 print $module->description;
533 if (in_array($name, $def)) {
534 print
'<td class="center">'.
"\n";
535 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'">';
536 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
540 print
'<td class="center">'.
"\n";
541 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>';
546 print
'<td class="center">';
547 $constforvar =
'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).
'_ADDON';
551 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>';
553 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>';
558 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
559 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
560 if ($module->type ==
'pdf') {
561 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
563 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
565 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
566 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
567 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
569 print
'<td class="center">';
570 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
574 print
'<td class="center">';
575 if ($module->type ==
'pdf') {
576 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
578 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
596if (empty($setupnotempty)) {
597 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 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.