ITopConsultant.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <?php
  2. // Copyright (C) 2010 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. /**
  17. * ITop consultant home page
  18. * tool box
  19. * object model analysis
  20. * DB integrity check and repair
  21. *
  22. * @author Erwan Taloc <erwan.taloc@combodo.com>
  23. * @author Romain Quetiez <romain.quetiez@combodo.com>
  24. * @author Denis Flaven <denis.flaven@combodo.com>
  25. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  26. */
  27. function sexyclass($sClass, $sBaseArgs)
  28. {
  29. return "Class <a href=\"?$sBaseArgs&todo=showclass&class=$sClass\">$sClass</a>";
  30. }
  31. function sexyclasslist($aClasses, $sBaseArgs)
  32. {
  33. if (count($aClasses) == 0) return "";
  34. $aRes = array();
  35. foreach($aClasses as $sClass)
  36. {
  37. $aRes[] = sexyclass($sClass, $sBaseArgs);
  38. }
  39. return ("'".implode("', '", $aRes)."'");
  40. }
  41. function ShowClass($sClass, $sBaseArgs)
  42. {
  43. if (!MetaModel::IsValidClass($sClass))
  44. {
  45. echo "Invalid class, expecting a value in {".sexyclasslist(MetaModel::GetClasses(), $sBaseArgs)."}<br/>\n";
  46. return;
  47. }
  48. // en recursif jusque "": MetaModel::GetParentPersistentClass($sClass)
  49. $aProps["Root class"] = MetaModel::GetRootClass($sClass);
  50. $aProps["Parent classes"] = sexyclasslist(MetaModel::EnumParentClasses($sClass), $sBaseArgs);
  51. $aProps["Child classes"] = sexyclasslist(MetaModel::EnumChildClasses($sClass), $sBaseArgs);
  52. $aProps["Subclasses (children + pure PHP)"] = sexyclasslist(MetaModel::GetSubclasses($sClass), $sBaseArgs);
  53. $aProps["Description"] = MetaModel::GetClassDescription($sClass);
  54. $aProps["Autoincrement id?"] = MetaModel::IsAutoIncrementKey($sClass);
  55. $aProps["Name attribute"] = MetaModel::GetNameAttributeCode($sClass);
  56. $aProps["Reconciliation keys"] = implode(", ", MetaModel::GetReconcKeys($sClass));
  57. $aProps["DB key column"] = MetaModel::DBGetKey($sClass);
  58. $aProps["DB class column"] = MetaModel::DBGetClassField($sClass);
  59. $aProps["Is standalone?"] = MetaModel::IsStandaloneClass($sClass);
  60. foreach (MetaModel::ListAttributeDefs($sClass) as $oAttDef)
  61. {
  62. $aAttProps = array();
  63. $aAttProps["Direct field"] = $oAttDef->IsDirectField();
  64. $aAttProps["External key"] = $oAttDef->IsExternalKey();
  65. $aAttProps["External field"] = $oAttDef->IsExternalField();
  66. $aAttProps["Link set"] = $oAttDef->IsLinkSet();
  67. $aAttProps["Code"] = $oAttDef->GetCode();
  68. $aAttProps["Label"] = $oAttDef->GetLabel();
  69. $aAttProps["Description"] = $oAttDef->GetDescription();
  70. $oValDef = $oAttDef->GetValuesDef();
  71. if (is_object($oValDef))
  72. {
  73. //$aAttProps["Allowed values"] = $oValDef->Describe();
  74. $aAttProps["Allowed values"] = "... object of class ".get_class($oValDef);
  75. }
  76. else
  77. {
  78. $aAttProps["Allowed values"] = "";
  79. }
  80. // MetaModel::IsAttributeInZList($sClass, $sListCode, $sAttCodeOrFltCode)
  81. }
  82. // $aProps["Description"] = MetaModel::DBGetTable($sClass, $sAttCode = null)
  83. $aAttributes = array();
  84. foreach (MetaModel::GetClassFilterDefs($sClass) as $oFilterDef)
  85. {
  86. $aAttProps = array();
  87. $aAttProps["Label"] = $oFilterDef->GetLabel();
  88. $aOpDescs = array();
  89. foreach ($oFilterDef->GetOperators() as $sOpCode => $sOpDescription)
  90. {
  91. $sIsTheLooser = ($sOpCode == $oFilterDef->GetLooseOperator()) ? " (loose search)" : "";
  92. $aOpDescs[] = "$sOpCode ($sOpDescription)$sIsTheLooser";
  93. }
  94. $aAttProps["Operators"] = implode(" / ", $aOpDescs);
  95. $aAttributes[] = $aAttProps;
  96. }
  97. $aProps["Filters"] = MyHelpers::make_table_from_assoc_array($aAttributes);
  98. foreach ($aProps as $sKey => $sDesc)
  99. {
  100. echo "<h4>$sKey</h4>\n";
  101. echo "<p>$sDesc</p>\n";
  102. }
  103. }
  104. function ShowBizModel($sBaseArgs)
  105. {
  106. echo "<ul>\n";
  107. foreach(MetaModel::GetClasses() as $sClass)
  108. {
  109. echo "<li>".sexyclass($sClass, $sBaseArgs)."</li>\n";
  110. }
  111. echo "</ul>\n";
  112. }
  113. function ShowZLists($sBaseArgs)
  114. {
  115. $aData = array();
  116. // 1 row per class, header made after the first row keys
  117. //
  118. foreach(MetaModel::GetClasses() as $sClass)
  119. {
  120. $aRow = array();
  121. $aRow["_"] = $sClass;
  122. foreach (MetaModel::EnumZLists() as $sListCode)
  123. {
  124. $aRow[$sListCode] = implode(", ", MetaModel::GetZListItems($sClass, $sListCode));
  125. }
  126. $aData[] = $aRow;
  127. }
  128. echo MyHelpers::make_table_from_assoc_array($aData);
  129. }
  130. function ShowDatabaseInfo()
  131. {
  132. $aTables = array();
  133. foreach (CMDBSource::EnumTables() as $sTable)
  134. {
  135. $aTableData = array();
  136. $aTableData["Name"] = $sTable;
  137. $aTableDesc = CMDBSource::GetTableInfo($sTable);
  138. $aTableData["Fields"] = MyHelpers::make_table_from_assoc_array($aTableDesc["Fields"]);
  139. $aTables[$sTable] = $aTableData;
  140. }
  141. echo MyHelpers::make_table_from_assoc_array($aTables);
  142. }
  143. function CreateDB()
  144. {
  145. $sRes = "<p>Creating the DB...</p>\n";
  146. if (MetaModel::DBExists(false))
  147. {
  148. $sRes .= "<p>It appears that the DB already exists (at least one table).</p>\n";
  149. }
  150. else
  151. {
  152. MetaModel::DBCreate();
  153. $sRes .= "<p>Done!</p>\n";
  154. }
  155. return $sRes;
  156. }
  157. function DebugQuery($sConfigFile)
  158. {
  159. $sQuery = ReadParam("oql");
  160. if (empty($sQuery))
  161. {
  162. $sQueryTemplate = "SELECT Foo AS f JOIN Dummy AS D ON d.spirit = f.id WHERE f.age * d.height > TO_DAYS(NOW()) OR d.alive";
  163. }
  164. else
  165. {
  166. $sQueryTemplate = $sQuery;
  167. }
  168. echo "<form>\n";
  169. echo "<input type=\"hidden\" name=\"todo\" value=\"debugquery\">\n";
  170. echo "<input type=\"hidden\" name=\"config\" value=\"$sConfigFile\">\n";
  171. echo "<textarea name=\"oql\" rows=\"10\" cols=\"120\" name=\"csvdata\" wrap=\"soft\">$sQueryTemplate</textarea>\n";
  172. echo "<input type=\"submit\" name=\"foo\">\n";
  173. echo "</form>\n";
  174. if (empty($sQuery)) return;
  175. echo "<h1>Testing query</h1>\n";
  176. echo "<p>$sQuery</p>\n";
  177. echo "<h1>Follow up the query build</h1>\n";
  178. MetaModel::StartDebugQuery();
  179. $oFlt = DBObjectSearch::FromOQL($sQuery);
  180. echo "<p>To OQL: ".$oFlt->ToOQL()."</p>";
  181. $sSQL = MetaModel::MakeSelectQuery($oFlt);
  182. MetaModel::StopDebugQuery();
  183. echo "<h1>Explain</h1>\n";
  184. echo "<table border=\"1\">\n";
  185. foreach (CMDBSource::ExplainQuery($sSQL) as $aRow)
  186. {
  187. echo " <tr>\n";
  188. echo " <td>".implode('</td><td>', $aRow)."</td>\n";
  189. echo " </tr>\n";
  190. }
  191. echo "</table>\n";
  192. echo "<h1>Results</h1>\n";
  193. $oSet = new CMDBObjectSet($oFlt);
  194. echo $oSet; // __toString()
  195. }
  196. function DumpDatabase()
  197. {
  198. $aData = MetaModel::DBDump();
  199. foreach ($aData as $sTable => $aRows)
  200. {
  201. echo "<h1>".htmlentities($sTable)."</h1>\n";
  202. if (count($aRows) == 0)
  203. {
  204. echo "<p>no data</p>\n";
  205. }
  206. else
  207. {
  208. echo "<p>".count($aRows)." row(s)</p>\n";
  209. // Table header
  210. echo "<table border=\"1\">\n";
  211. echo "<tr>\n";
  212. foreach (reset($aRows) as $key => $value)
  213. {
  214. echo "<th>".htmlentities($key)."</th>";
  215. }
  216. echo "</tr>\n";
  217. // Table body
  218. foreach ($aRows as $aRow)
  219. {
  220. echo "<tr>\n";
  221. foreach ($aRow as $key => $value)
  222. {
  223. echo "<td>".htmlentities($value)."</td>";
  224. }
  225. echo "</tr>\n";
  226. }
  227. echo "</table>\n";
  228. }
  229. }
  230. }
  231. /////////////////////////////////////////////////////////////////////////////////////
  232. // Helper functions
  233. /////////////////////////////////////////////////////////////////////////////////////
  234. function printMenu($sConfigFile)
  235. {
  236. $sClassCount = count(MetaModel::GetClasses());
  237. $bHasDB = MetaModel::DBExists(false); // no need to be complete to consider that something already exists
  238. $sUrl = "?config=".urlencode($sConfigFile);
  239. echo "<div style=\"background-color:eeeeee; padding:10px;\">\n";
  240. echo "<h2>phpMyORM integration sandbox</h2>\n";
  241. echo "<h4>Target database: $sConfigFile</h4>\n";
  242. echo "<p>$sClassCount classes referenced in the model</p>\n";
  243. echo "<ul>";
  244. echo " <li><a href=\"$sUrl&todo=checkdictionary&categories=bizmodel&outputfilter=NotInDictionary\">Dictionary - missing entries (EN US)</a></li>";
  245. echo " <li><a href=\"$sUrl&todo=dictionarystats\">Dictionary - statistics by language</a></li>";
  246. echo " <li><a href=\"$sUrl&todo=checkmodel\">Biz model consistency</a></li>";
  247. echo " <li><a href=\"$sUrl&todo=showzlists\">Show ZLists</a></li>";
  248. echo " <li><a href=\"$sUrl&todo=showbizmodel\">Browse business model</a></li>";
  249. if ($bHasDB)
  250. {
  251. echo " <li><a href=\"$sUrl&todo=checkmodeltodb\">Concordance between Biz model and <b>DB format</b></a></li>";
  252. echo " <li><a href=\"$sUrl&todo=checkmodeltoviews\">Concordance between Biz model and <b>Views</b></a></li>";
  253. echo " <li><a href=\"$sUrl&todo=checkdb\">DB integrity check</a></li>";
  254. echo " <li><a href=\"$sUrl&todo=checkall\">Any check at once (see list above)</a></li>";
  255. echo " <li><a href=\"$sUrl&todo=userrightssetup\">Setup userrights (init DB)</a></li>";
  256. echo " <li><a href=\"$sUrl&todo=showtables\">Show Tables</a></li>";
  257. echo " <li><a href=\"$sUrl&todo=debugquery\">Test an OQL query (debug)</a></li>";
  258. echo " <li><a href=\"$sUrl&todo=dumpdb\">Dump database</a></li>";
  259. // echo " <li>".htmlentities($sUrl)."&amp;<b>todo=execsql</b>&amp;<b>sql=xxx</b>, to execute a specific sql request</li>";
  260. }
  261. else
  262. {
  263. echo " <li><a href=\"$sUrl&todo=createdb\">Create the DB</a></li>";
  264. }
  265. echo "</ul>";
  266. echo "</div>\n";
  267. }
  268. function printConfigList()
  269. {
  270. echo "<h2>phpMyORM integration sandbox</h2>\n";
  271. echo "<h4>Configuration sumary</h4>\n";
  272. $sBasePath = '..';
  273. $aConfigs = array();
  274. foreach(scandir($sBasePath) as $sFile)
  275. {
  276. if (preg_match('/^config-.+\\.php$/', $sFile)) $aConfigs[] = $sFile;
  277. }
  278. $aConfigDetails = array();
  279. foreach ($aConfigs as $sConfigFile)
  280. {
  281. $sRealPath = $sBasePath.'/'.$sConfigFile;
  282. $oConfig = new Config($sRealPath);
  283. $sAppModules = implode(', ', $oConfig->GetAppModules());
  284. $sDataModels = implode(', ', $oConfig->GetDataModels());
  285. $sAddons = implode(', ', $oConfig->GetAddons());
  286. $sDBSubname = (strlen($oConfig->GetDBSubname()) > 0) ? '('.$oConfig->GetDBSubname().')' : '';
  287. $sUrl = "?config=".urlencode($sRealPath);
  288. $sHLink = "<a href=\"$sUrl\">Manage <b>$sConfigFile</b></a></br>\n";
  289. $aConfigDetails[] = array('Config'=>$sHLink, 'Application'=>$sAppModules, 'Data models'=>$sDataModels, 'Addons'=>$sAddons, 'Database'=>$oConfig->GetDBHost().'/'.$oConfig->GetDBName().$sDBSubname.' as '.$oConfig->GetDBUser());
  290. }
  291. echo MyHelpers::make_table_from_assoc_array($aConfigDetails);
  292. }
  293. function ReadParam($sName, $defaultValue = "")
  294. {
  295. return isset($_REQUEST[$sName]) ? $_REQUEST[$sName] : $defaultValue;
  296. }
  297. function ReadMandatoryParam($sName)
  298. {
  299. $value = ReadParam($sName, null);
  300. if (is_null($value))
  301. {
  302. echo "<p>Missing mandatory argument <b>$sName</b></p>";
  303. exit;
  304. }
  305. return $value;
  306. }
  307. function DisplayDBFormatIssues($aErrors, $aSugFix, $sRepairUrl = "", $sSQLStatementArgName = "")
  308. {
  309. $aSQLFixes = array(); // each and every SQL repair statement
  310. if (count($aErrors) > 0)
  311. {
  312. echo "<div style=\"width:100%;padding:10px;background:#FFAAAA;display:;\">";
  313. echo "<h1>Wrong Database format</h1>\n";
  314. echo "<p>The current database is not consistent with the given business model. Please investigate.</p>\n";
  315. foreach ($aErrors as $sClass => $aTarget)
  316. {
  317. echo "<p>Wrong declaration (or DB format ?) for class <b>$sClass</b></p>\n";
  318. echo "<ul class=\"treeview\">\n";
  319. $i = 0;
  320. foreach ($aTarget as $sTarget => $aMessages)
  321. {
  322. if ($sTarget != '*')
  323. {
  324. echo "<p>Wrong declaration for attribute <b>$sTarget</b></p>\n";
  325. }
  326. $sMsg = implode(' AND ', $aMessages);
  327. if (!empty($sRepairUrl))
  328. {
  329. $aSQLFixes = array_merge($aSQLFixes, $aSugFix[$sClass][$sTarget]);
  330. $aCleanFixes = array();
  331. foreach($aSugFix[$sClass][$sTarget] as $sSQLFix)
  332. {
  333. if (!empty($sSQLFix))
  334. {
  335. $aCleanFixes[] = $sSQLFix;
  336. }
  337. }
  338. if (count($aCleanFixes) > 0)
  339. {
  340. $sSQLFixes = implode('; ', $aCleanFixes);
  341. $sUrl = "$sRepairUrl&$sSQLStatementArgName=".urlencode($sSQLFixes);
  342. echo "<li>$sMsg (<a href=\"$sUrl\" title=\"".htmlentities($sSQLFixes)."\" target=\"_blank\">fix it now!</a>)</li>\n";
  343. }
  344. else
  345. {
  346. echo "<li>$sMsg</li>\n";
  347. }
  348. }
  349. else
  350. {
  351. echo "<li>$sMsg (".htmlentities($sSQLFixes).")</li>\n";
  352. }
  353. $i++;
  354. }
  355. echo "</ul>\n";
  356. }
  357. if (count($aSQLFixes) > 1)
  358. {
  359. MetaModel::DBShowApplyForm($sRepairUrl, $sSQLStatementArgName, $aSQLFixes);
  360. }
  361. echo "<p>Aborting...</p>\n";
  362. echo "</div>\n";
  363. exit;
  364. }
  365. }
  366. /////////////////////////////////////////////////////////////////////////////////////////////////
  367. //
  368. // M a i n P r o g r a m
  369. //
  370. /////////////////////////////////////////////////////////////////////////////////////////////////
  371. require_once('../core/cmdbobject.class.inc.php');
  372. $sConfigFile = ReadParam("config", '');
  373. if (empty($sConfigFile))
  374. {
  375. printConfigList();
  376. exit;
  377. }
  378. MetaModel::Startup($sConfigFile, true); // allow missing DB
  379. $sBaseArgs = "config=".urlencode($sConfigFile);
  380. $sTodo = ReadParam("todo", "");
  381. if ($sTodo == 'execsql')
  382. {
  383. $sSql = ReadMandatoryParam("sql");
  384. $aSql = explode("##SEP##", $sSql);
  385. $sConfirm = ReadParam("confirm");
  386. if (empty($sConfirm) || ($sConfirm != "Yes"))
  387. {
  388. echo "<form method=\"post\" action=\"?$sBaseArgs\">\n";
  389. echo "<input type=\"hidden\" name=\"todo\" value=\"execsql\">\n";
  390. echo "<input type=\"hidden\" name=\"sql\" value=\"".htmlentities($sSql)."\">\n";
  391. if (count($aSql) == 1)
  392. {
  393. echo "Do you confirm that you want to execute this command: <b>".htmlentities($aSql[0])."</b> ?</br>\n";
  394. }
  395. else
  396. {
  397. $sAllQueries = "<li>".implode("</li>\n<li>", $aSql)."</li>\n";
  398. echo "Please confirm that you want to execute these commands: <ul style=\"font-size: smaller;\">".$sAllQueries."</ul>\n";
  399. }
  400. echo "<input type=\"submit\" name=\"confirm\" value=\"Yes\">\n";
  401. echo "</form>\n";
  402. }
  403. else
  404. {
  405. foreach ($aSql as $sOneSingleSql)
  406. {
  407. echo "Executing command: <b>$sOneSingleSql</b></br>\n";
  408. CMDBSource::Query($sOneSingleSql);
  409. echo "... done!</br>\n";
  410. }
  411. }
  412. }
  413. else
  414. {
  415. $sBaseUrl = "?$sBaseArgs&todo=execsql";
  416. switch ($sTodo)
  417. {
  418. case "createdb":
  419. // do NOT print the menu, because it will change...
  420. break;
  421. default:
  422. printMenu($sConfigFile);
  423. }
  424. switch ($sTodo)
  425. {
  426. case "showtables":
  427. ShowDatabaseInfo();
  428. break;
  429. case "showbizmodel":
  430. ShowBizModel($sBaseArgs);
  431. break;
  432. case "showclass":
  433. $sClass = ReadMandatoryParam("class");
  434. ShowClass($sClass, $sBaseArgs);
  435. break;
  436. case "showzlists":
  437. ShowZLists($sBaseArgs);
  438. break;
  439. case "debugquery":
  440. DebugQuery($sConfigFile);
  441. break;
  442. case "createdb":
  443. $sRes = CreateDB();
  444. // As the menu depends on the existence of the DB, we have to do display it right after the job is done
  445. printMenu($sConfigFile);
  446. echo $sRes;
  447. break;
  448. case "dictionarystats":
  449. echo "Dictionary: statistics by language<br/>\n";
  450. foreach (Dict::GetLanguages() as $sLanguageCode => $aLanguageData)
  451. {
  452. list($aMissing, $aUnexpected, $aNotTranslated, $aOK) = Dict::MakeStats($sLanguageCode, 'EN US');
  453. echo "<p>Stats for language: $sLanguageCode</p>\n";
  454. echo "<ul><li>Missing:".count($aMissing)."</li><li>Unexpected:".count($aUnexpected)."</li><li>NotTranslated:".count($aNotTranslated)."</li><li>OK:".count($aOK)."</li></ul>\n";
  455. }
  456. break;
  457. case "checkdictionary":
  458. $sCategories = ReadMandatoryParam("categories");
  459. $sOutputFilter = ReadParam("outputfilter", '');
  460. echo "Dictionary: missing entries (categories: $sCategories, output: '$sOutputFilter')</br>\n";
  461. echo "<pre>\n";
  462. echo MetaModel::MakeDictionaryTemplate($sCategories, $sOutputFilter);
  463. echo "</pre>\n";
  464. break;
  465. case "checkmodel":
  466. echo "Check definitions...</br>\n";
  467. MetaModel::CheckDefinitions();
  468. echo "done...</br>\n";
  469. break;
  470. case "checkmodeltodb":
  471. echo "Check DB format...</br>\n";
  472. list($aErrors, $aSugFix) = MetaModel::DBCheckFormat();
  473. DisplayDBFormatIssues($aErrors, $aSugFix, $sBaseUrl, $sSQLStatementArgName = "sql");
  474. echo "done...</br>\n";
  475. break;
  476. case "checkmodeltoviews":
  477. echo "Check Views...</br>\n";
  478. list($aErrors, $aSugFix) = MetaModel::DBCheckViews();
  479. DisplayDBFormatIssues($aErrors, $aSugFix, $sBaseUrl, $sSQLStatementArgName = "sql");
  480. echo "done...</br>\n";
  481. break;
  482. case "checkdb":
  483. echo "Check DB integrity...</br>\n";
  484. MetaModel::DBCheckIntegrity($sBaseUrl, "sql");
  485. echo "done...</br>\n";
  486. break;
  487. case "dumpdb":
  488. echo "Dump DB data...</br>\n";
  489. DumpDatabase();
  490. echo "done...</br>\n";
  491. break;
  492. case "userrightssetup":
  493. echo "Setup user rights module (init DB)...</br>\n";
  494. UserRights::Setup();
  495. echo "done...</br>\n";
  496. break;
  497. case "checkall":
  498. echo "Check definitions...</br>\n";
  499. MetaModel::CheckDefinitions();
  500. echo "done...</br>\n";
  501. echo "Check DB format...</br>\n";
  502. list($aErrors, $aSugFix) = MetaModel::DBCheckFormat();
  503. DisplayDBFormatIssues($aErrors, $aSugFix, $sBaseUrl, $sSQLStatementArgName = "sql");
  504. echo "done...</br>\n";
  505. echo "Check Views...</br>\n";
  506. list($aErrors, $aSugFix) = MetaModel::DBCheckViews();
  507. DisplayDBFormatIssues($aErrors, $aSugFix, $sBaseUrl, $sSQLStatementArgName = "sql");
  508. echo "done...</br>\n";
  509. echo "Check DB integrity...</br>\n";
  510. MetaModel::DBCheckIntegrity($sBaseUrl, "sql");
  511. echo "done...</br>\n";
  512. break;
  513. }
  514. }
  515. ?>