From: dj3c1t Date: Thu, 31 Oct 2013 19:15:24 +0000 (+0100) Subject: informations de versions X-Git-Tag: mtweb.0.11.2 X-Git-Url: http://git.dj3c1t.com/?p=mtweb;a=commitdiff_plain;h=bec31526c19092982057acabfe12e121442ec19b informations de versions --- diff --git a/mw/app/config.xml b/mw/app/config.xml index 1118636..69c3103 100644 --- a/mw/app/config.xml +++ b/mw/app/config.xml @@ -1,6 +1,8 @@ + 0.11.2 + #-- diff --git a/mw/app/controllers/install/index.php b/mw/app/controllers/install/index.php index 8407538..1decc17 100644 --- a/mw/app/controllers/install/index.php +++ b/mw/app/controllers/install/index.php @@ -57,6 +57,7 @@ "user" => isset($_POST[$current_sgbd."_user"]) ? $_POST[$current_sgbd."_user"] : "", "password" => isset($_POST[$current_sgbd."_password"]) ? $_POST[$current_sgbd."_password"] : "" ); + $sgbds[$current_sgbd]->user = $params["user"]; $admin = array( "login" => trim($_POST["admin_login"]), "email" => trim($_POST["admin_email"]), diff --git a/mw/app/data/modules/sql/mw_data_sql_install.php b/mw/app/data/modules/sql/mw_data_sql_install.php index 19a8a8d..22b86dc 100644 --- a/mw/app/data/modules/sql/mw_data_sql_install.php +++ b/mw/app/data/modules/sql/mw_data_sql_install.php @@ -22,13 +22,17 @@ catch(Exception $e){ return $e->getMessage(); } + if(!($version = $env->version("mtweb"))){ + return "impossible de lire la version de mtweb"; + } try{ $EXISTS = $sgbd->table_exists("#--actions_roles") || $sgbd->table_exists("#--config") || $sgbd->table_exists("#--roles") || $sgbd->table_exists("#--users") - || $sgbd->table_exists("#--users_roles"); + || $sgbd->table_exists("#--users_roles") + || $sgbd->table_exists("#--versions"); } catch(Exception $e){ return "impossible de savoir si les tables existent deja"; @@ -89,6 +93,15 @@ .") DEFAULT CHARSET=utf8"; $sgbd->query($sql); + $sql = + "CREATE TABLE #--versions(" + ." id INT(11) NOT NULL AUTO_INCREMENT," + ." application VARCHAR(255) NOT NULL," + ." version VARCHAR(255) NOT NULL," + ." PRIMARY KEY (id)" + .") DEFAULT CHARSET=utf8"; + $sgbd->query($sql); + } catch(Exception $e){ return "imposible de creer les tables en base"; @@ -126,6 +139,11 @@ ."(3, 'webmaster', 'webmaster')"; $sgbd->query($sql); + $sql = + "INSERT INTO #--versions(`application`, `version`) VALUES" + ."('mtweb', ".$this->eq($version).")"; + $sgbd->query($sql); + } catch(Exception $e){ return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut."; diff --git a/mw/app/data/modules/sql/mw_data_sqlite_install.php b/mw/app/data/modules/sql/mw_data_sqlite_install.php index 8c26638..2f241f6 100644 --- a/mw/app/data/modules/sql/mw_data_sqlite_install.php +++ b/mw/app/data/modules/sql/mw_data_sqlite_install.php @@ -28,13 +28,17 @@ catch(Exception $e){ return $e->getMessage(); } + if(!($version = $env->version("mtweb"))){ + return "impossible de lire la version de mtweb"; + } try{ $EXISTS = $sgbd->table_exists("#--actions_roles") || $sgbd->table_exists("#--config") || $sgbd->table_exists("#--roles") || $sgbd->table_exists("#--users") - || $sgbd->table_exists("#--users_roles"); + || $sgbd->table_exists("#--users_roles") + || $sgbd->table_exists("#--versions"); } catch(Exception $e){ return "impossible de savoir si les tables existent deja"; @@ -85,6 +89,14 @@ .")"; $sgbd->query($sql); + $sql = + "CREATE TABLE #--versions(" + ." id INTEGER PRIMARY KEY AUTOINCREMENT," + ." application TEXT NOT NULL," + ." version TEXT NOT NULL" + .")"; + $sgbd->query($sql); + } catch(Exception $e){ return "imposible de creer les tables en base. ".$e->getMessage(); @@ -153,6 +165,10 @@ "INSERT INTO #--roles(`id`, `nom`, `intitule`) VALUES (3, 'webmaster', 'webmaster')"; $sgbd->query($sql); + $sql = + "INSERT INTO #--versions(`application`, `version`) VALUES ('mtweb', ".$this->eq($version).")"; + $sgbd->query($sql); + } catch(Exception $e){ return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut."; diff --git a/mw/app/data/modules/xml/mw_data_xml_install.php b/mw/app/data/modules/xml/mw_data_xml_install.php index 9bebcf9..61bfe96 100644 --- a/mw/app/data/modules/xml/mw_data_xml_install.php +++ b/mw/app/data/modules/xml/mw_data_xml_install.php @@ -32,6 +32,9 @@ ){ return "impossible de se connecter à la base XML"; } + if(!($version = $env->version("mtweb"))){ + return "impossible de lire la version de mtweb"; + } $ERROR = false; $EXISTS = false; if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("actions_roles"); @@ -44,6 +47,8 @@ $ERROR = !isset($EXISTS); if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("users_roles"); $ERROR = !isset($EXISTS); + if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("versions"); + $ERROR = !isset($EXISTS); if($ERROR){ return "impossible de savoir si les tables existent deja"; } @@ -55,6 +60,7 @@ if(!$ERROR) if(!$sgbd->create_data("roles")) $ERROR = true; if(!$ERROR) if(!$sgbd->create_data("users")) $ERROR = true; if(!$ERROR) if(!$sgbd->create_data("users_roles")) $ERROR = true; + if(!$ERROR) if(!$sgbd->create_data("versions")) $ERROR = true; if($ERROR){ return "imposible de creer les tables en base"; } @@ -247,6 +253,19 @@ ) ) $ERROR = true; + // ------------------------------------ versions + if(!$ERROR){ + $res = $sgbd->add_data( + "versions", + array( + "application" => "mtweb", + "version" => $version + ), + 0 + ); + if(!isset($res)) $ERROR = true; + } + if($ERROR){ return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut."; } diff --git a/mw/env/modules/mw_env_versions.php b/mw/env/modules/mw_env_versions.php new file mode 100644 index 0000000..7c6c09c --- /dev/null +++ b/mw/env/modules/mw_env_versions.php @@ -0,0 +1,43 @@ +versions[$application]) ? $this->versions[$application] : false; + } + + function load_versions(){ + $this->xml_parser = new sxml(); + $app_config_file = $this->path("mw_dir")."app/config.xml"; + if(file_exists($app_config_file)){ + $this->_load_version("mtweb", $app_config_file); + } + if(($plugins = $this->plugins()) !== false){ + foreach($plugins as $plugin_name => $plugin){ + $this->load_plugin_version($plugin_name); + } + } + else $this->erreur("impossible de lire les fichiers de configuration pour les plugins", true); + } + + function _load_version($app_name, $app_config_file){ + $this->xml_parser->parse(file_get_contents($app_config_file)); + $app_config = $this->xml_parser->data["config"][0]; + if(isset($app_config["subs"]["version"][0]["data"])){ + $this->versions[$app_name] = $app_config["subs"]["version"][0]["data"]; + } + } + + function load_plugin_version($plugin_name){ + $app_config_file = $this->path("mw_dir")."plugins/".$plugin_name."/app/config.xml"; + if(file_exists($app_config_file)){ + $this->_load_version($plugin_name, $app_config_file); + } + } + + } + +?> \ No newline at end of file diff --git a/mw/mw_app.php b/mw/mw_app.php index 9af31bc..d1f6148 100644 --- a/mw/mw_app.php +++ b/mw/mw_app.php @@ -147,6 +147,7 @@ $env->set_config_file($this->config_file); $env->set_PATHES($this->pathes); $env->init_plugins(); + $env->load_versions(); $env->load_config($this->bdd, $this->config); $env->init(); return true;