mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Clean code for #28785
This commit is contained in:
parent
5fadea4d0d
commit
28269b1a0a
|
|
@ -102,41 +102,6 @@ if ($action == 'updateMask') {
|
|||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
} elseif ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/eventorganization/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} elseif ($action == 'setmod') {
|
||||
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
|
|
|
|||
|
|
@ -66,6 +66,11 @@ $setupnotempty = 0;
|
|||
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
$moduledir = 'hrm';
|
||||
$myTmpObjects = array();
|
||||
// TODO Scan list of objects to fill this array
|
||||
$myTmpObjects['evaluation'] = array('label' => 'Evaluation', 'includerefgeneration' => 1, 'includedocgeneration' => 0);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
|
@ -109,38 +114,40 @@ if ($action == 'update') {
|
|||
}
|
||||
} elseif ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
$tmpobjectkey = GETPOST('object', 'aZ09');
|
||||
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
if (in_array($tmpobjectkey, $myTmpObjects)) {
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/hrm/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/hrm/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} elseif ($action == 'setmod') {
|
||||
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
|
||||
|
|
@ -209,9 +216,6 @@ print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
|
|||
$head = hrmAdminPrepareHead();
|
||||
print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "hrm");
|
||||
|
||||
$moduledir = 'hrm';
|
||||
$myTmpObjects = array();
|
||||
$myTmpObjects['evaluation'] = array('label' => 'Evaluation', 'includerefgeneration' => 1, 'includedocgeneration' => 0);
|
||||
|
||||
foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
if ($myTmpObjectKey != $type) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ $scandir = GETPOST('scan_dir', 'alpha');
|
|||
$type = 'knowledgemanagement';
|
||||
|
||||
$arrayofparameters = array(
|
||||
'KNOWLEDGEMANAGEMENT_MYPARAM1' => array('type' => 'string', 'css' => 'minwidth500' ,'enabled' => 0),
|
||||
//'KNOWLEDGEMANAGEMENT_MYPARAM1' => array('type' => 'string', 'css' => 'minwidth500' ,'enabled' => 0),
|
||||
//'KNOWLEDGEMANAGEMENT_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
|
||||
//'KNOWLEDGEMANAGEMENT_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
|
||||
//'KNOWLEDGEMANAGEMENT_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),
|
||||
|
|
@ -62,6 +62,11 @@ if (!$user->admin) {
|
|||
accessforbidden();
|
||||
}
|
||||
|
||||
$moduledir = 'knowledgemanagement';
|
||||
$myTmpObjects = array();
|
||||
// TODO Scan list of objects to fill this array
|
||||
$myTmpObjects['knowledgemanagement'] = array('label'=>'KnowledgeManagement', 'includerefgeneration'=>0, 'includedocgeneration'=>0, 'class'=>'KnowledgeManagement');
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
|
@ -87,38 +92,40 @@ if ($action == 'updateMask') {
|
|||
}
|
||||
} elseif ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
$tmpobjectkey = GETPOST('object', 'aZ09');
|
||||
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
if (in_array($tmpobjectkey, $myTmpObjects)) {
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/knowledgemanagement/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/knowledgemanagement/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} elseif ($action == 'setmod') {
|
||||
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
|
||||
|
|
|
|||
|
|
@ -90,41 +90,6 @@ if ($action == 'updateMask') {
|
|||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
} elseif ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/webhook/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele."_".strtolower($tmpobjectkey);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=webhook-".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} elseif ($action == 'setmod') {
|
||||
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
|
|
@ -375,269 +340,6 @@ if ($action == 'edit') {
|
|||
}
|
||||
|
||||
|
||||
$moduledir = 'webhook';
|
||||
$myTmpObjects = array();
|
||||
$myTmpObjects['MyObject'] = array('includerefgeneration' => 0, 'includedocgeneration' => 0);
|
||||
|
||||
|
||||
foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
if ($myTmpObjectKey == 'MyObject') {
|
||||
continue;
|
||||
}
|
||||
if ($myTmpObjectArray['includerefgeneration']) {
|
||||
/*
|
||||
* Orders Numbering model
|
||||
*/
|
||||
$setupnotempty++;
|
||||
|
||||
print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Name").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td class="nowrap">'.$langs->trans("Example").'</td>';
|
||||
print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
|
||||
print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$dir = dol_buildpath($reldir."core/modules/".$moduledir);
|
||||
|
||||
if (is_dir($dir)) {
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
require_once $dir.'/'.$file.'.php';
|
||||
|
||||
$module = new $file($db);
|
||||
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
|
||||
continue;
|
||||
}
|
||||
if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($module->isEnabled()) {
|
||||
dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
|
||||
|
||||
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
|
||||
print $module->info($langs);
|
||||
print '</td>';
|
||||
|
||||
// Show example of numbering model
|
||||
print '<td class="nowrap">';
|
||||
$tmp = $module->getExample();
|
||||
if (preg_match('/^Error/', $tmp)) {
|
||||
$langs->load("errors");
|
||||
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||
} elseif ($tmp == 'NotConfigured') {
|
||||
print $langs->trans($tmp);
|
||||
} else {
|
||||
print $tmp;
|
||||
}
|
||||
print '</td>'."\n";
|
||||
|
||||
print '<td class="center">';
|
||||
$constforvar = 'WEBHOOK_'.strtoupper($myTmpObjectKey).'_ADDON';
|
||||
if (getDolGlobalString($constforvar) == $file) {
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
} else {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$mytmpinstance = new $myTmpObjectKey($db);
|
||||
$mytmpinstance->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip = '';
|
||||
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
|
||||
$nextval = $module->getNextValue($mytmpinstance);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
|
||||
$htmltooltip .= ''.$langs->trans("NextValue").': ';
|
||||
if ($nextval) {
|
||||
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
|
||||
$nextval = $langs->trans($nextval);
|
||||
}
|
||||
$htmltooltip .= $nextval.'<br>';
|
||||
} else {
|
||||
$htmltooltip .= $langs->trans($module->error).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
print '<td class="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
print "</table><br>\n";
|
||||
}
|
||||
|
||||
if ($myTmpObjectArray['includedocgeneration']) {
|
||||
/*
|
||||
* Document templates generators
|
||||
*/
|
||||
$setupnotempty++;
|
||||
$type = strtolower($myTmpObjectKey);
|
||||
|
||||
print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
|
||||
|
||||
// Load array def with activated templates
|
||||
$def = array();
|
||||
$sql = "SELECT nom";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = '".$db->escape($type)."'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows) {
|
||||
$array = $db->fetch_array($resql);
|
||||
array_push($def, $array[0]);
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print "<table class=\"noborder\" width=\"100%\">\n";
|
||||
print "<tr class=\"liste_titre\">\n";
|
||||
print '<td>'.$langs->trans("Name").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
|
||||
print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
|
||||
print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
|
||||
print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
foreach ($dirmodels as $reldir) {
|
||||
foreach (array('', '/doc') as $valdir) {
|
||||
$realpath = $reldir."core/modules/".$moduledir.$valdir;
|
||||
$dir = dol_buildpath($realpath);
|
||||
|
||||
if (is_dir($dir)) {
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle)) {
|
||||
$filelist = array();
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
$filelist[] = $file;
|
||||
}
|
||||
closedir($handle);
|
||||
arsort($filelist);
|
||||
|
||||
foreach ($filelist as $file) {
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
|
||||
if (file_exists($dir.'/'.$file)) {
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db);
|
||||
|
||||
$modulequalified = 1;
|
||||
if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
|
||||
$modulequalified = 0;
|
||||
}
|
||||
|
||||
if ($modulequalified) {
|
||||
print '<tr class="oddeven"><td width="100">';
|
||||
print(empty($module->name) ? $name : $module->name);
|
||||
print "</td><td>\n";
|
||||
if (method_exists($module, 'info')) {
|
||||
print $module->info($langs);
|
||||
} else {
|
||||
print $module->description;
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Active
|
||||
if (in_array($name, $def)) {
|
||||
print '<td class="center">'."\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
|
||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td class="center">'."\n";
|
||||
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>';
|
||||
print "</td>";
|
||||
}
|
||||
|
||||
// Default
|
||||
print '<td class="center">';
|
||||
$constforvar = 'WEBHOOK_'.strtoupper($myTmpObjectKey).'_ADDON';
|
||||
if (getDolGlobalString($constforvar) == $name) {
|
||||
//print img_picto($langs->trans("Default"), 'on');
|
||||
// Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&token='.newToken().'&object='.urlencode(strtolower($myTmpObjectKey)).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
|
||||
} else {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&object='.urlencode(strtolower($myTmpObjectKey)).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
if ($module->type == 'pdf') {
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
}
|
||||
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
|
||||
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
|
||||
|
||||
print '<td class="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||
print '</td>';
|
||||
|
||||
// Preview
|
||||
print '<td class="center">';
|
||||
if ($module->type == 'pdf') {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
|
||||
} else {
|
||||
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($setupnotempty)) {
|
||||
print '<br>'.$langs->trans("NothingToSetup");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ if (!$user->admin) {
|
|||
accessforbidden();
|
||||
}
|
||||
|
||||
$moduledir = 'workstation';
|
||||
$myTmpObjects = array();
|
||||
$myTmpObjects['workstation'] = array('includerefgeneration' => 1, 'includedocgeneration' => 0);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
|
@ -77,38 +82,40 @@ if ($action == 'updateMask') {
|
|||
}
|
||||
} elseif ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
$tmpobjectkey = GETPOST('object', 'aZ09');
|
||||
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
if (in_array($tmpobjectkey, $myTmpObjects)) {
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/workstation/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/workstation/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} elseif ($action == 'set') {
|
||||
// Activate a model
|
||||
|
|
@ -219,11 +226,6 @@ if ($action == 'edit') {
|
|||
}
|
||||
|
||||
|
||||
$moduledir = 'workstation';
|
||||
$myTmpObjects = array();
|
||||
$myTmpObjects['workstation'] = array('includerefgeneration' => 1, 'includedocgeneration' => 0);
|
||||
|
||||
|
||||
foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
if ($myTmpObjectKey == 'MyObject') {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -104,41 +104,6 @@ if ($action == 'updateMask') {
|
|||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
} elseif ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/ai/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele."_".strtolower($tmpobjectkey);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bookcal-".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} elseif ($action == 'setmod') {
|
||||
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ $setupnotempty = 0;
|
|||
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
$moduledir = 'asset';
|
||||
$myTmpObjects = array();
|
||||
$myTmpObjects['Asset'] = array('includerefgeneration' => 1, 'includedocgeneration' => 0);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
|
@ -89,38 +93,40 @@ if ($action == 'updateMask') {
|
|||
}
|
||||
} elseif ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
$tmpobjectkey = GETPOST('object', 'aZ09');
|
||||
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
if (in_array($tmpobjectkey, $myTmpObjects)) {
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/asset/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/asset/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} elseif ($action == 'setmod') {
|
||||
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
|
||||
|
|
@ -194,10 +200,6 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "asse
|
|||
echo '<span class="opacitymedium">'.$langs->trans("AssetSetupPage").'</span>';
|
||||
|
||||
|
||||
$moduledir = 'asset';
|
||||
$myTmpObjects = array();
|
||||
$myTmpObjects['Asset'] = array('includerefgeneration' => 1, 'includedocgeneration' => 0);
|
||||
|
||||
|
||||
foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
if ($myTmpObjectKey == 'MyObject') {
|
||||
|
|
|
|||
|
|
@ -136,41 +136,6 @@ if ($action == 'updateMask') {
|
|||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
} elseif ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/bookcal/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$classname = "pdf_".$modele."_".strtolower($tmpobjectkey);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($classname !== '') {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bookcal-".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} elseif ($action == 'setmod') {
|
||||
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
|
|
|
|||
|
|
@ -1297,7 +1297,7 @@ class Cronjob extends CommonObject
|
|||
dol_syslog(get_class($this)."::run_jobs START ".$this->objectname."->".$this->methodename."(".$this->params."); (Note: Log for cron jobs may be into a different log file)", LOG_DEBUG);
|
||||
|
||||
// Create Object for the called module
|
||||
$nameofclass = $this->objectname;
|
||||
$nameofclass = (string) $this->objectname;
|
||||
$object = new $nameofclass($this->db);
|
||||
if ($this->entity > 0) {
|
||||
$object->entity = $this->entity; // We work on a dedicated entity
|
||||
|
|
|
|||
|
|
@ -64,9 +64,9 @@ if ($action == 'specimen') {
|
|||
$dir = DOL_DOCUMENT_ROOT."/core/modules/dons/";
|
||||
$file = $modele.".modules.php";
|
||||
if ($modele !== '' && file_exists($dir.$file)) {
|
||||
$classname = $modele;
|
||||
require_once $dir.$file;
|
||||
|
||||
$classname = (string) $modele;
|
||||
$obj = new $classname($db);
|
||||
|
||||
if ($obj->write_file($don, $langs) > 0) {
|
||||
|
|
|
|||
|
|
@ -171,6 +171,11 @@ $setupnotempty += count($formSetup->items);
|
|||
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
|
||||
$moduledir = 'mymodule';
|
||||
$myTmpObjects = array();
|
||||
// TODO Scan list of objects to fill this array
|
||||
$myTmpObjects['myobject'] = array('label'=>'MyObject', 'includerefgeneration'=>0, 'includedocgeneration'=>0, 'class'=>'MyObject');
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
|
@ -201,40 +206,42 @@ if ($action == 'updateMask') {
|
|||
}
|
||||
} elseif ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
$tmpobjectkey = GETPOST('object', 'aZ09');
|
||||
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
if (in_array($tmpobjectkey, $myTmpObjects)) {
|
||||
$tmpobject = new $tmpobjectkey($db);
|
||||
$tmpobject->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/mymodule/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele."_".strtolower($tmpobjectkey);
|
||||
break;
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/mymodule/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file)) {
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele."_".strtolower($tmpobjectkey);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($filefound) {
|
||||
require_once $file;
|
||||
if ($filefound) {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mymodule-".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mymodule-".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($module->error, null, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
} elseif ($action == 'setmod') {
|
||||
// TODO Check if numbering module chosen can be activated by calling method canBeActivated
|
||||
|
|
@ -327,12 +334,6 @@ if (!empty($formSetup->items)) {
|
|||
}
|
||||
|
||||
|
||||
$moduledir = 'mymodule';
|
||||
$myTmpObjects = array();
|
||||
// TODO Scan list of objects
|
||||
$myTmpObjects['myobject'] = array('label'=>'MyObject', 'includerefgeneration'=>0, 'includedocgeneration'=>0, 'class'=>'MyObject');
|
||||
|
||||
|
||||
foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
if ($myTmpObjectArray['includerefgeneration']) {
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user