diff options
Diffstat (limited to 'installer')
-rw-r--r-- | installer/rcube_install.php | 43 | ||||
-rw-r--r-- | installer/test.php | 9 |
2 files changed, 43 insertions, 9 deletions
diff --git a/installer/rcube_install.php b/installer/rcube_install.php index b0d59fd29..ae568d223 100644 --- a/installer/rcube_install.php +++ b/installer/rcube_install.php @@ -40,8 +40,8 @@ class rcube_install 'addrbook_show_images' => 'show_images', ); - // these config options are optional or can be set to null - var $required_config = array('db_dsnw', 'des_key'); + // these config options are required for a working system + var $required_config = array('db_dsnw', 'db_table_contactgroups', 'db_table_contactgroupmembers', 'des_key'); /** * Constructor @@ -325,6 +325,43 @@ class rcube_install } } + /** + * Compare the local database schema with the reference schema + * required for this version of RoundCube + * + * @param boolean True if the schema schould be updated + * @return boolean True if the schema is up-to-date, false if not or an error occured + */ + function db_schema_check($DB, $update = false) + { + if (!$this->configured) + return false; + + // simple ad hand-made db schema + $db_schema = array( + 'users' => array(), + 'identities' => array(), + 'contacts' => array(), + 'contactgroups' => array(), + 'contactgroupmembers' => array(), + 'cache' => array(), + 'messages' => array(), + 'session' => array(), + ); + + $errors = array(); + + // check list of tables + $existing_tables = $DB->list_tables(); + foreach ($db_schema as $table => $cols) { + if (!in_array($this->config['db_table_'.$table], $existing_tables)) + $errors[] = "Missing table ".$table; + + // TODO: check cols and indices + } + + return !empty($errors) ? $errors : false; + } /** * Compare the local database schema with the reference schema @@ -333,7 +370,7 @@ class rcube_install * @param boolean True if the schema schould be updated * @return boolean True if the schema is up-to-date, false if not or an error occured */ - function db_schema_check($update = false) + function mdb2_schema_check($update = false) { if (!$this->configured) return false; diff --git a/installer/test.php b/installer/test.php index 1495715d5..66698d7ad 100644 --- a/installer/test.php +++ b/installer/test.php @@ -164,15 +164,12 @@ if ($db_working) { echo '<p><input type="submit" name="initdb" value="Initialize database" /></p>'; $db_working = false; } - /* - else if (!$RCI->db_schema_check($update = !empty($_POST['updatedb']))) { + else if ($RCI->db_schema_check($DB, $update = !empty($_POST['updatedb']))) { $RCI->fail('DB Schema', "Database schema differs"); - - echo $update ? '<p class="warning">Failed to update the database schema! Please manually execute the SQL statements from the SQL/*.update.sql file on your database</p>' : - '<p><input type="submit" name="updatedb" value="Update schema now" /></p>'; + $updatefile = INSTALL_PATH . 'SQL/' . $DB->db_provider . '.update.sql'; + echo '<p class="warning">Please manually execute the SQL statements from '.$updatefile.' on your database</p>'; $db_working = false; } - */ else { $RCI->pass('DB Schema'); echo '<br />'; |