partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 5932ec56ea66aa81dc4e71013dea24fd39727ac4
parent 0844f2114d1053b6d768397bdf3a095552dfea08
Author: Felicitus <felicitus@felicitus.org>
Date:   Sat, 31 Dec 2011 16:04:11 +0100

Added check for an up-to-date schema on login

Diffstat:
Msrc/backend/de/RaumZeitLabor/PartKeepr/System/SystemService.php | 21+++++++++++++++++++++
Msrc/frontend/js/PartKeepr.js | 22++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/System/SystemService.php b/src/backend/de/RaumZeitLabor/PartKeepr/System/SystemService.php @@ -56,4 +56,25 @@ class SystemService extends Service { // TODO: add information about post max, file upload size, timeout, memory limit return array("data" => $aData); } + + /** + * Returns the database schema status. + * + * This method is usuall called once the user logs in, and alerts him if the schema is not up-to-date. + * + * Returns either status incomplete if the schema is not up-to-date, or complete if everything is OK. + */ + public function getDatabaseSchemaStatus () { + $metadatas = PartKeepr::getEM()->getMetadataFactory()->getAllMetadata(); + + $schemaTool = new \Doctrine\ORM\Tools\SchemaTool(PartKeepr::getEM()); + + $queries = $schemaTool->getUpdateSchemaSql($metadatas, true); + + if (count($queries) > 0) { + return array("data" => array("status" => "incomplete")); + } else { + return array("data" => array("status" => "complete")); + } + } } \ No newline at end of file diff --git a/src/frontend/js/PartKeepr.js b/src/frontend/js/PartKeepr.js @@ -49,6 +49,8 @@ Ext.application({ this.addItem(j); this.menuBar.enable(); + this.doSchemaCheck(); + /* Give the user preference stuff enough time to load */ /* @todo Load user preferences directly on login and not via delayed task */ this.displayTipWindowTask = new Ext.util.DelayedTask(this.displayTipOfTheDayWindow, this); @@ -81,6 +83,26 @@ Ext.application({ } } }, + /** + * Does a schema status call against the PartKeepr installation, in order to verify if the schema is up-to-date. + * + * @param none + * @return nothing + */ + doSchemaCheck: function () { + var call = new PartKeepr.ServiceCall("System", "getDatabaseSchemaStatus"); + call.setHandler(Ext.bind(this.onSchemaChecked, this)); + call.doCall(); + }, + /** + * Handler for the schema check + * @param data The data returned from the server + */ + onSchemaChecked: function (data) { + if (data.data.status !== "complete") { + alert(i18n("Your database schema is not up-to-date! Please re-run setup immediately!")); + } + }, logout: function () { this.menuBar.disable(); this.centerPanel.removeAll(true);