diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php
index 058802978fd..7d9197d10b6 100644
--- a/htdocs/install/repair.php
+++ b/htdocs/install/repair.php
@@ -802,90 +802,108 @@ if ($ok && GETPOST('force_disable_of_modules_not_found','alpha'))
{
print '
*** Force modules not found to be disabled |
';
- $sql ="SELECT DISTINCT name";
- $sql.=" FROM ".MAIN_DB_PREFIX."const as c";
- $sql.=" WHERE name LIKE 'MAIN_MODULE_%_HOOKS'";
- $sql.=" ORDER BY name";
+ $arraylistofkey=array('hooks','js','css');
- $resql = $db->query($sql);
- if ($resql)
+ foreach($arraylistofkey as $key)
{
- $num = $db->num_rows($resql);
- if ($num)
- {
- $i = 0;
- while ($i < $num)
- {
- $obj=$db->fetch_object($resql);
- $majname = $obj->name;
+ $sql ="SELECT DISTINCT name, value";
+ $sql.=" FROM ".MAIN_DB_PREFIX."const as c";
+ $sql.=" WHERE name LIKE 'MAIN_MODULE_%_".strtoupper($key)."'";
+ $sql.=" ORDER BY name";
- print '| ';
- print $majname;
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ if ($num)
+ {
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj=$db->fetch_object($resql);
+ $constantname = $obj->name; // Name of constant for hook or js or css declaration
- $db->begin();
+ print ' |
| ';
+ print $constantname;
- if (preg_match('/MAIN_MODULE_(.*)_HOOKS/i', $majname, $reg))
- {
- $name=strtolower($reg[1]);
+ $db->begin();
- if ($name)
- {
- $reloffile=$name.'/class/actions_'.$name.'.class.php';
- $result = dol_include_once($reloffile);
- if (! $result)
- {
- print ' - File of hooks ('.$reloffile.') NOT found, we disable the module.';
- if (GETPOST('force_disable_of_modules_not_found') == 'confirmed')
- {
- $sql2 ="DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."_HOOKS'";
- $resql2=$db->query($sql2);
- if (! $resql2)
- {
- $error++;
- dol_print_error($db);
- }
- $sql2 ="DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."'";
- $resql2=$db->query($sql2);
- if (! $resql2)
- {
- $error++;
- dol_print_error($db);
- }
- else
- print " - Cleaned";
- }
- else
- {
- print ' - Canceled (test mode)';
- }
- }
- else
- {
- print ' - File of hooks ('.$reloffile.') found, we do nothing.';
- }
- }
+ if (preg_match('/MAIN_MODULE_(.*)_'.strtoupper($key).'/i', $constantname, $reg))
+ {
+ $name=strtolower($reg[1]);
- if (!$error) $db->commit();
- else $db->rollback();
- }
+ if ($name) // And entry for key $key and module $name was found in database.
+ {
+ if ($key == 'hooks') $reloffile=$name.'/class/actions_'.$name.'.class.php';
+ if ($key == 'js')
+ {
+ $value=$obj->value;
+ $valuearray=json_decode($value);
+ $reloffile=$valuearray[0];
+ $reloffile=preg_replace('/^\//','',$valuearray[0]);
+ }
+ if ($key == 'css')
+ {
+ $value=$obj->value;
+ $valuearray=json_decode($value);
+ $reloffile=preg_replace('/^\//','',$valuearray[0]);
+ }
- print' |
';
+ $result = dol_include_once($reloffile);
+ if (! $result)
+ {
+ print ' - File of '.$key.' ('.$reloffile.') NOT found, we disable the module.';
+ if (GETPOST('force_disable_of_modules_not_found') == 'confirmed')
+ {
+ $sql2 ="DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."_".strtoupper($key)."'";
+ $resql2=$db->query($sql2);
+ if (! $resql2)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ $sql2 ="DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."'";
+ $resql2=$db->query($sql2);
+ if (! $resql2)
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ else
+ print " - Cleaned";
+ }
+ else
+ {
+ print ' - Canceled (test mode)';
+ }
+ }
+ else
+ {
+ print ' - File of '.$key.' ('.$reloffile.') found, we do nothing.';
+ }
+ }
- if ($error) break;
+ if (!$error) $db->commit();
+ else $db->rollback();
+ }
- $i++;
- }
- }
- else
- {
- print '| No active module with missing files found |
';
- }
+ print'';
+
+ if ($error) break;
+
+ $i++;
+ }
+ }
+ else
+ {
+ print '| No active module with missing files found by searching on MAIN_MODULE_(.*)_'.strtoupper($key).' |
';
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
}
- else
- {
- dol_print_error($db);
- }
-
}