"#--" => $table_prefix
)
);
- $current_sgbd = "mw_pdo_sqlite";
+ $current_sgbd = isset($sgbds["mw_pdo_sqlite"]) ? "mw_pdo_sqlite" : "mw_xml";
if($_POST){
if(!isset($_POST["sgbd"])){
$env->erreur("Parametre de SGBD manquant");
--- /dev/null
+<?php
+
+ class mw_data_versions extends mw_data{
+
+ function version($application_name){
+ if(
+ $version = $this->data_read(
+ array(
+ "table_name" => "versions",
+ "index_name" => "application",
+ "index_value" => $application_name
+ )
+ )
+ ) return $version["version"];
+ return false;
+ }
+
+ }
<?php
- if(!$this->bdd("sgbd")) return;
+ if($this->bdd_ready() !== true) return;
if(($config = $data->config()) !== false){
$this->set_config($config);
$start_action_params_config =
<?php
- if(!$this->bdd("sgbd")) return;
+ if($this->bdd_ready() !== true) return;
if($data->load_session() !== false){
if($data->init_roles() !== false){
if($data->init_actions_roles() === false){
+++ /dev/null
-<?php
-
- if(($check_instance_return = $data->check_instance()) !== false){
- if($check_instance_return !== true){
- $this->erreur($check_instance_return, true);
- }
- }
- else $this->erreur("Impossible de verifier l'integrité de la base de donné", true);
-
-?>
\ No newline at end of file
<?php
+ if($this->bdd_ready() !== true) return;
if($this->init_links()){
$this->set_link("users/infos", $this->url("users/infos"), "Compte", 10);
$this->set_link("admin/users", $this->url("admin/users"), "Utilisateurs", 20);
<?php
+ if($this->bdd_ready() !== true) return;
if(($plugins = $this->plugins("DESC")) !== false){
foreach($plugins as $plugin_name => $plugin){
if($plugin["installed"] && $plugin["enabled"]){
<li>Afficher les utilisateurs pour</li>
<li>
<select onchange="document.location=this.options[this.selectedIndex].value;">
- <option value="<?php echo $this->url("admin/users", $users_params); ?>"<?php echo $_GET[$this->param("alpha")] ? "" : " selected=\"selected\""; ?>>Tous les logins</option>
+ <option value="<?php echo $this->url("admin/users", $users_params); ?>"<?php echo (isset($_GET[$this->param("alpha")]) && $_GET[$this->param("alpha")]) ? "" : " selected=\"selected\""; ?>>Tous les logins</option>
<?php for($i = 65; $i <= 90; $i++) : $users_params["alpha"] = chr($i); ?>
- <option value="<?php echo $this->url("admin/users", $users_params); ?>"<?php echo $_GET[$this->param("alpha")] == chr($i) ? " selected=\"selected\"" : ""; ?>><?php echo chr($i); ?></option>
+ <option value="<?php echo $this->url("admin/users", $users_params); ?>"<?php echo (isset($_GET[$this->param("alpha")]) && ($_GET[$this->param("alpha")] == chr($i))) ? " selected=\"selected\"" : ""; ?>><?php echo chr($i); ?></option>
<?php endfor; ?>
</select>
</li>
?>
<li>
<select onchange="document.location=this.options[this.selectedIndex].value;">
- <option value="<?php echo $this->url("admin/users", $users_params); ?>"<?php echo $_GET[$this->param("role")] ? "" : " selected=\"selected\""; ?>>Tous les roles</option>
+ <option value="<?php echo $this->url("admin/users", $users_params); ?>"<?php echo (isset($_GET[$this->param("role")]) && $_GET[$this->param("role")]) ? "" : " selected=\"selected\""; ?>>Tous les roles</option>
<?php foreach($this->out["roles"] as $role) : if($role["id"]) : $users_params["role"] = $role["id"]; ?>
- <option value="<?php echo $this->url("admin/users", $users_params); ?>"<?php echo $_GET[$this->param("role")] == $role["id"] ? " selected=\"selected\"" : ""; ?>><?php echo $role["intitule"]; ?></option>
+ <option value="<?php echo $this->url("admin/users", $users_params); ?>"<?php echo (isset($_GET[$this->param("role")]) && ($_GET[$this->param("role")] == $role["id"])) ? " selected=\"selected\"" : ""; ?>><?php echo $role["intitule"]; ?></option>
<?php endif; endforeach; ?>
</select>
</li>
$this->bdd[$key] = $value;
}
+ function bdd_ready(){
+ if(!$this->bdd("sgbd")) return "aucun sgbd defini";
+ $data = $this->data();
+ if(!$data) return "objet data non defini";
+ if(!$this->version("mtweb")) return "impossible de lire la version de mtweb";
+ if($data->version("mtweb") != $this->version("mtweb")) return "la version de la base et du code sont différentes";
+ return true;
+ }
+
function add_table_prefix($table_prefix){
if(is_array($table_prefix)){
foreach($table_prefix as $prefix_code => $prefix) $this->bdd["table_prefix"][$prefix_code] = $prefix;
if(!$this->init_pathes()) return $this->get_error();
if(!$this->init_config()) return $this->get_error();
if(!$this->init_env()) return $this->get_error();
- if($this->config_file) return true;
- if($this->DO_SETUP) $this->setup();
- return $this->get_error();
+ if(!$this->config_file){
+ if($this->DO_SETUP){
+ $this->setup();
+ exit;
+ }
+ return $this->get_error();
+ }
+ $env = $this->env();
+ if(!$env->version("mtweb")){
+ $this->error("impossible de lire la version du code");
+ return $this->get_error();
+ }
+ $data = $env->data();
+ if($data->version("mtweb") != $env->version("mtweb")){
+ $this->upgrade();
+ exit;
+ }
+ return true;
}
function init_pathes(){
$etat = isset($_GET[$env->param("e")]) ? $_GET[$env->param("e")] : "install";
$env->run($etat, array(), false);
$this->display();
- exit;
+ }
+
+ function upgrade(){
+ debug("la base de données doit être mise à jour");
}
function error($content){