knowledgemanagement.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <?php
  2. /* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2021 SuperAdmin
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file knowledgemanagement/admin/setup.php
  20. * \ingroup knowledgemanagement
  21. * \brief KnowledgeManagement setup page.
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. global $langs, $user;
  26. // Libraries
  27. require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
  28. require_once DOL_DOCUMENT_ROOT."/knowledgemanagement/lib/knowledgemanagement.lib.php";
  29. // Translations
  30. $langs->loadLangs(array("admin", "knowledgemanagement"));
  31. // Parameters
  32. $action = GETPOST('action', 'aZ09');
  33. $backtopage = GETPOST('backtopage', 'alpha');
  34. $value = GETPOST('value', 'alpha');
  35. $label = GETPOST('label', 'alpha');
  36. $scandir = GETPOST('scan_dir', 'alpha');
  37. $type = 'knowledgemanagement';
  38. $arrayofparameters = array(
  39. 'KNOWLEDGEMANAGEMENT_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>0),
  40. //'KNOWLEDGEMANAGEMENT_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
  41. //'KNOWLEDGEMANAGEMENT_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
  42. //'KNOWLEDGEMANAGEMENT_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),
  43. //'KNOWLEDGEMANAGEMENT_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1),
  44. //'KNOWLEDGEMANAGEMENT_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1),
  45. );
  46. $error = 0;
  47. $setupnotempty = 0;
  48. // Access control
  49. if (!$user->admin) {
  50. accessforbidden();
  51. }
  52. /*
  53. * Actions
  54. */
  55. if ((float) DOL_VERSION >= 6) {
  56. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  57. }
  58. if ($action == 'updateMask') {
  59. $maskconstorder = GETPOST('maskconstorder', 'alpha');
  60. $maskorder = GETPOST('maskorder', 'alpha');
  61. if ($maskconstorder) {
  62. $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
  63. if (!($res > 0)) {
  64. $error++;
  65. }
  66. }
  67. if (!$error) {
  68. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  69. } else {
  70. setEventMessages($langs->trans("Error"), null, 'errors');
  71. }
  72. } elseif ($action == 'specimen') {
  73. $modele = GETPOST('module', 'alpha');
  74. $tmpobjectkey = GETPOST('object');
  75. $tmpobject = new $tmpobjectkey($db);
  76. $tmpobject->initAsSpecimen();
  77. // Search template files
  78. $file = ''; $classname = ''; $filefound = 0;
  79. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  80. foreach ($dirmodels as $reldir) {
  81. $file = dol_buildpath($reldir."core/modules/knowledgemanagement/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
  82. if (file_exists($file)) {
  83. $filefound = 1;
  84. $classname = "pdf_".$modele;
  85. break;
  86. }
  87. }
  88. if ($filefound) {
  89. require_once $file;
  90. $module = new $classname($db);
  91. if ($module->write_file($tmpobject, $langs) > 0) {
  92. header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
  93. return;
  94. } else {
  95. setEventMessages($module->error, null, 'errors');
  96. dol_syslog($module->error, LOG_ERR);
  97. }
  98. } else {
  99. setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
  100. dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
  101. }
  102. } elseif ($action == 'setmod') {
  103. // TODO Check if numbering module chosen can be activated by calling method canBeActivated
  104. $tmpobjectkey = GETPOST('object');
  105. if (!empty($tmpobjectkey)) {
  106. $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey)."_ADDON";
  107. dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
  108. }
  109. } elseif ($action == 'set') {
  110. // Activate a model
  111. $ret = addDocumentModel($value, $type, $label, $scandir);
  112. } elseif ($action == 'del') {
  113. $ret = delDocumentModel($value, $type);
  114. if ($ret > 0) {
  115. $tmpobjectkey = GETPOST('object');
  116. if (!empty($tmpobjectkey)) {
  117. $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
  118. if ($conf->global->$constforval == "$value") {
  119. dolibarr_del_const($db, $constforval, $conf->entity);
  120. }
  121. }
  122. }
  123. } elseif ($action == 'setdoc') {
  124. // Set or unset default model
  125. $tmpobjectkey = GETPOST('object');
  126. if (!empty($tmpobjectkey)) {
  127. $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
  128. if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
  129. // The constant that was read before the new set
  130. // We therefore requires a variable to have a coherent view
  131. $conf->global->$constforval = $value;
  132. }
  133. // We disable/enable the document template (into llx_document_model table)
  134. $ret = delDocumentModel($value, $type);
  135. if ($ret > 0) {
  136. $ret = addDocumentModel($value, $type, $label, $scandir);
  137. }
  138. }
  139. } elseif ($action == 'unsetdoc') {
  140. $tmpobjectkey = GETPOST('object');
  141. if (!empty($tmpobjectkey)) {
  142. $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
  143. dolibarr_del_const($db, $constforval, $conf->entity);
  144. }
  145. }
  146. /*
  147. * View
  148. */
  149. $form = new Form($db);
  150. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  151. $page_name = "KnowledgeManagementSetup";
  152. llxHeader('', $langs->trans($page_name));
  153. // Subheader
  154. $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
  155. print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
  156. // Configuration header
  157. $head = knowledgemanagementAdminPrepareHead();
  158. print dol_get_fiche_head($head, 'setup', $langs->trans('ModuleKnowledgeManagementName'), -1, "knowledgemanagement");
  159. // Setup page goes here
  160. echo '<span class="opacitymedium">'.$langs->trans("KnowledgeManagementSetupPage").'</span><br><br>';
  161. if ($action == 'edit') {
  162. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  163. print '<input type="hidden" name="token" value="'.newToken().'">';
  164. print '<input type="hidden" name="action" value="update">';
  165. print '<table class="noborder centpercent">';
  166. print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  167. foreach ($arrayofparameters as $constname => $val) {
  168. if ($val['enabled']==1) {
  169. $setupnotempty++;
  170. print '<tr class="oddeven"><td>';
  171. $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
  172. print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
  173. print '</td><td>';
  174. if ($val['type'] == 'textarea') {
  175. print '<textarea class="flat" name="'.$constname.'" id="'.$constname.'" cols="50" rows="5" wrap="soft">' . "\n";
  176. print $conf->global->{$constname};
  177. print "</textarea>\n";
  178. } elseif ($val['type']== 'html') {
  179. require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
  180. $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
  181. $doleditor->Create();
  182. } elseif ($val['type'] == 'yesno') {
  183. print $form->selectyesno($constname, $conf->global->{$constname}, 1);
  184. } elseif (preg_match('/emailtemplate:/', $val['type'])) {
  185. include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
  186. $formmail = new FormMail($db);
  187. $tmp = explode(':', $val['type']);
  188. $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
  189. //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
  190. $arrayofmessagename = array();
  191. if (is_array($formmail->lines_model)) {
  192. foreach ($formmail->lines_model as $modelmail) {
  193. //var_dump($modelmail);
  194. $moreonlabel = '';
  195. if (!empty($arrayofmessagename[$modelmail->label])) {
  196. $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
  197. }
  198. // The 'label' is the key that is unique if we exclude the language
  199. $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel;
  200. }
  201. }
  202. print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
  203. } elseif (preg_match('/category:/', $val['type'])) {
  204. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  205. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  206. $formother = new FormOther($db);
  207. $tmp = explode(':', $val['type']);
  208. print img_picto('', 'category', 'class="pictofixedwidth"');
  209. print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
  210. } elseif (preg_match('/thirdparty_type/', $val['type'])) {
  211. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  212. $formcompany = new FormCompany($db);
  213. print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname);
  214. } else {
  215. print '<input name="'.$constname.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->{$constname}.'">';
  216. }
  217. print '</td></tr>';
  218. }
  219. }
  220. print '</table>';
  221. print $form->buttonsSaveCancel("Save", '');
  222. print '</form>';
  223. print '<br>';
  224. } else {
  225. if (!empty($arrayofparameters)) {
  226. print '<table class="noborder centpercent">';
  227. print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  228. foreach ($arrayofparameters as $constname => $val) {
  229. if ($val['enabled']==1) {
  230. $setupnotempty++;
  231. print '<tr class="oddeven"><td>';
  232. $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
  233. print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
  234. print '</td><td>';
  235. if ($val['type'] == 'textarea') {
  236. print dol_nl2br($conf->global->{$constname});
  237. } elseif ($val['type']== 'html') {
  238. print $conf->global->{$constname};
  239. } elseif ($val['type'] == 'yesno') {
  240. print ajax_constantonoff($constname);
  241. } elseif (preg_match('/emailtemplate:/', $val['type'])) {
  242. include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
  243. $formmail = new FormMail($db);
  244. $tmp = explode(':', $val['type']);
  245. $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
  246. if ($template<0) {
  247. setEventMessages(null, $formmail->errors, 'errors');
  248. }
  249. print $langs->trans($template->label);
  250. } elseif (preg_match('/category:/', $val['type'])) {
  251. $c = new Categorie($db);
  252. $result = $c->fetch($conf->global->{$constname});
  253. if ($result < 0) {
  254. setEventMessages(null, $c->errors, 'errors');
  255. }
  256. $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
  257. $toprint = array();
  258. foreach ($ways as $way) {
  259. $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
  260. }
  261. print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
  262. } elseif (preg_match('/thirdparty_type/', $val['type'])) {
  263. if ($conf->global->{$constname}==2) {
  264. print $langs->trans("Prospect");
  265. } elseif ($conf->global->{$constname}==3) {
  266. print $langs->trans("ProspectCustomer");
  267. } elseif ($conf->global->{$constname}==1) {
  268. print $langs->trans("Customer");
  269. } elseif ($conf->global->{$constname}==0) {
  270. print $langs->trans("NorProspectNorCustomer");
  271. }
  272. } else {
  273. print $conf->global->{$constname};
  274. }
  275. print '</td></tr>';
  276. }
  277. }
  278. print '</table>';
  279. print '<div class="tabsAction">';
  280. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
  281. print '</div>';
  282. } else {
  283. //print '<br>'.$langs->trans("NothingToSetup");
  284. }
  285. }
  286. $moduledir = 'knowledgemanagement';
  287. $myTmpObjects = array();
  288. $myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
  289. foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
  290. if ($myTmpObjectKey == 'MyObject') {
  291. continue;
  292. }
  293. if ($myTmpObjectArray['includerefgeneration']) {
  294. /*
  295. * Orders Numbering model
  296. */
  297. $setupnotempty++;
  298. print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
  299. print '<table class="noborder centpercent">';
  300. print '<tr class="liste_titre">';
  301. print '<td>'.$langs->trans("Name").'</td>';
  302. print '<td>'.$langs->trans("Description").'</td>';
  303. print '<td class="nowrap">'.$langs->trans("Example").'</td>';
  304. print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
  305. print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
  306. print '</tr>'."\n";
  307. clearstatcache();
  308. foreach ($dirmodels as $reldir) {
  309. $dir = dol_buildpath($reldir."core/modules/".$moduledir);
  310. if (is_dir($dir)) {
  311. $handle = opendir($dir);
  312. if (is_resource($handle)) {
  313. while (($file = readdir($handle)) !== false) {
  314. if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
  315. $file = substr($file, 0, dol_strlen($file) - 4);
  316. require_once $dir.'/'.$file.'.php';
  317. $module = new $file($db);
  318. // Show modules according to features level
  319. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  320. continue;
  321. }
  322. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  323. continue;
  324. }
  325. if ($module->isEnabled()) {
  326. dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
  327. print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
  328. print $module->info();
  329. print '</td>';
  330. // Show example of numbering model
  331. print '<td class="nowrap">';
  332. $tmp = $module->getExample();
  333. if (preg_match('/^Error/', $tmp)) {
  334. $langs->load("errors");
  335. print '<div class="error">'.$langs->trans($tmp).'</div>';
  336. } elseif ($tmp == 'NotConfigured') {
  337. print $langs->trans($tmp);
  338. } else {
  339. print $tmp;
  340. }
  341. print '</td>'."\n";
  342. print '<td class="center">';
  343. $constforvar = 'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).'_ADDON';
  344. if ($conf->global->$constforvar == $file) {
  345. print img_picto($langs->trans("Activated"), 'switch_on');
  346. } else {
  347. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
  348. print img_picto($langs->trans("Disabled"), 'switch_off');
  349. print '</a>';
  350. }
  351. print '</td>';
  352. $mytmpinstance = new $myTmpObjectKey($db);
  353. $mytmpinstance->initAsSpecimen();
  354. // Info
  355. $htmltooltip = '';
  356. $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
  357. $nextval = $module->getNextValue($mytmpinstance);
  358. if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
  359. $htmltooltip .= ''.$langs->trans("NextValue").': ';
  360. if ($nextval) {
  361. if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
  362. $nextval = $langs->trans($nextval);
  363. }
  364. $htmltooltip .= $nextval.'<br>';
  365. } else {
  366. $htmltooltip .= $langs->trans($module->error).'<br>';
  367. }
  368. }
  369. print '<td class="center">';
  370. print $form->textwithpicto('', $htmltooltip, 1, 0);
  371. print '</td>';
  372. print "</tr>\n";
  373. }
  374. }
  375. }
  376. closedir($handle);
  377. }
  378. }
  379. }
  380. print "</table><br>\n";
  381. }
  382. if ($myTmpObjectArray['includedocgeneration']) {
  383. /*
  384. * Document templates generators
  385. */
  386. $setupnotempty++;
  387. $type = strtolower($myTmpObjectKey);
  388. print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
  389. // Load array def with activated templates
  390. $def = array();
  391. $sql = "SELECT nom";
  392. $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
  393. $sql .= " WHERE type = '".$db->escape($type)."'";
  394. $sql .= " AND entity = ".$conf->entity;
  395. $resql = $db->query($sql);
  396. if ($resql) {
  397. $i = 0;
  398. $num_rows = $db->num_rows($resql);
  399. while ($i < $num_rows) {
  400. $array = $db->fetch_array($resql);
  401. array_push($def, $array[0]);
  402. $i++;
  403. }
  404. } else {
  405. dol_print_error($db);
  406. }
  407. print "<table class=\"noborder\" width=\"100%\">\n";
  408. print "<tr class=\"liste_titre\">\n";
  409. print '<td>'.$langs->trans("Name").'</td>';
  410. print '<td>'.$langs->trans("Description").'</td>';
  411. print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
  412. print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
  413. print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
  414. print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
  415. print "</tr>\n";
  416. clearstatcache();
  417. foreach ($dirmodels as $reldir) {
  418. foreach (array('', '/doc') as $valdir) {
  419. $realpath = $reldir."core/modules/".$moduledir.$valdir;
  420. $dir = dol_buildpath($realpath);
  421. if (is_dir($dir)) {
  422. $handle = opendir($dir);
  423. if (is_resource($handle)) {
  424. while (($file = readdir($handle)) !== false) {
  425. $filelist[] = $file;
  426. }
  427. closedir($handle);
  428. arsort($filelist);
  429. foreach ($filelist as $file) {
  430. if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
  431. if (file_exists($dir.'/'.$file)) {
  432. $name = substr($file, 4, dol_strlen($file) - 16);
  433. $classname = substr($file, 0, dol_strlen($file) - 12);
  434. require_once $dir.'/'.$file;
  435. $module = new $classname($db);
  436. $modulequalified = 1;
  437. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  438. $modulequalified = 0;
  439. }
  440. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  441. $modulequalified = 0;
  442. }
  443. if ($modulequalified) {
  444. print '<tr class="oddeven"><td width="100">';
  445. print (empty($module->name) ? $name : $module->name);
  446. print "</td><td>\n";
  447. if (method_exists($module, 'info')) {
  448. print $module->info($langs);
  449. } else {
  450. print $module->description;
  451. }
  452. print '</td>';
  453. // Active
  454. if (in_array($name, $def)) {
  455. print '<td class="center">'."\n";
  456. print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
  457. print img_picto($langs->trans("Enabled"), 'switch_on');
  458. print '</a>';
  459. print '</td>';
  460. } else {
  461. print '<td class="center">'."\n";
  462. print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.urlencode($module->scandir).'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
  463. print "</td>";
  464. }
  465. // Default
  466. print '<td class="center">';
  467. $constforvar = 'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).'_ADDON';
  468. if ($conf->global->$constforvar == $name) {
  469. //print img_picto($langs->trans("Default"), 'on');
  470. // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
  471. print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  472. } else {
  473. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.urlencode($module->scandir).'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  474. }
  475. print '</td>';
  476. // Info
  477. $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
  478. $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
  479. if ($module->type == 'pdf') {
  480. $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
  481. }
  482. $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
  483. $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  484. $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
  485. $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
  486. print '<td class="center">';
  487. print $form->textwithpicto('', $htmltooltip, 1, 0);
  488. print '</td>';
  489. // Preview
  490. print '<td class="center">';
  491. if ($module->type == 'pdf') {
  492. print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
  493. } else {
  494. print img_object($langs->trans("PreviewNotAvailable"), 'generic');
  495. }
  496. print '</td>';
  497. print "</tr>\n";
  498. }
  499. }
  500. }
  501. }
  502. }
  503. }
  504. }
  505. }
  506. print '</table>';
  507. }
  508. }
  509. if (empty($setupnotempty)) {
  510. print '<br>'.$langs->trans("NothingToSetup");
  511. }
  512. // Page end
  513. print dol_get_fiche_end();
  514. llxFooter();
  515. $db->close();