Skip to content
Snippets Groups Projects
Commit d7c8f4d5 authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: compatibility with external modules

parent 872f580b
No related branches found
No related tags found
No related merge requests found
...@@ -36,11 +36,13 @@ $langs->load("admin"); ...@@ -36,11 +36,13 @@ $langs->load("admin");
$langs->load("errors"); $langs->load("errors");
$langs->load("interventions"); $langs->load("interventions");
if (!$user->admin) if (! $user->admin) accessforbidden();
accessforbidden();
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$value = GETPOST('value','alpha'); $value = GETPOST('value','alpha');
$label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha');
$type='ficheinter';
/* /*
...@@ -146,30 +148,13 @@ if ($action == 'specimen') ...@@ -146,30 +148,13 @@ if ($action == 'specimen')
if ($action == 'set') if ($action == 'set')
{ {
$label = GETPOST('label','alpha'); $ret = addDocumentModel($value, $type, $label, $scandir);
$scandir = GETPOST('scandir','alpha');
$type='ficheinter';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")";
if ($db->query($sql))
{
}
} }
if ($action == 'del') if ($action == 'del')
{ {
$type='ficheinter'; $ret = delDocumentModel($value, $type);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; if ($ret > 0)
$sql.= " WHERE nom = '".$db->escape($value)."'";
$sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
if ($db->query($sql))
{ {
if ($conf->global->FICHEINTER_ADDON_PDF == "$value") dolibarr_del_const($db, 'FICHEINTER_ADDON_PDF',$conf->entity); if ($conf->global->FICHEINTER_ADDON_PDF == "$value") dolibarr_del_const($db, 'FICHEINTER_ADDON_PDF',$conf->entity);
} }
...@@ -177,11 +162,6 @@ if ($action == 'del') ...@@ -177,11 +162,6 @@ if ($action == 'del')
if ($action == 'setdoc') if ($action == 'setdoc')
{ {
$label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha');
$db->begin();
if (dolibarr_set_const($db, "FICHEINTER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) if (dolibarr_set_const($db, "FICHEINTER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{ {
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
...@@ -190,28 +170,10 @@ if ($action == 'setdoc') ...@@ -190,28 +170,10 @@ if ($action == 'setdoc')
} }
// On active le modele // On active le modele
$type='ficheinter'; $ret = delDocumentModel($value, $type);
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; if ($ret > 0)
$sql_del.= " WHERE nom = '".$db->escape($value)."'";
$sql_del.= " AND type = '".$type."'";
$sql_del.= " AND entity = ".$conf->entity;
dol_syslog("fichinter: sql_del=".$sql_del);
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")";
dol_syslog("fichinter: sql_del=".$sql_del);
$result2=$db->query($sql);
if ($result1 && $result2)
{
$db->commit();
}
else
{ {
$db->rollback(); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} }
...@@ -372,9 +334,9 @@ print "</tr>\n"; ...@@ -372,9 +334,9 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
$var=true; $var=true;
foreach ($conf->file->dol_document_root as $dirroot) foreach ($dirmodels as $reldir)
{ {
$dir = $dirroot . "/core/modules/fichinter/doc/"; $dir = dol_buildpath($reldir."core/modules/fichinter/doc/");
if (is_dir($dir)) if (is_dir($dir))
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment